| 817 | f.add_done_callback(self._loop_self_reading) |
| 818 | |
| 819 | def _write_to_self(self): |
| 820 | # This may be called from a different thread, possibly after |
| 821 | # _close_self_pipe() has been called or even while it is |
| 822 | # running. Guard for self._csock being None or closed. When |
| 823 | # a socket is closed, send() raises OSError (with errno set to |
| 824 | # EBADF, but let's not rely on the exact error code). |
| 825 | csock = self._csock |
| 826 | if csock is None: |
| 827 | return |
| 828 | |
| 829 | try: |
| 830 | csock.send(b'\0') |
| 831 | except OSError: |
| 832 | if self._debug: |
| 833 | logger.debug("Fail to write a null byte into the " |
| 834 | "self-pipe socket", |
| 835 | exc_info=True) |
| 836 | |
| 837 | def _start_serving(self, protocol_factory, sock, |
| 838 | sslcontext=None, server=None, backlog=100, |