| 140 | break |
| 141 | |
| 142 | def _write_to_self(self): |
| 143 | # This may be called from a different thread, possibly after |
| 144 | # _close_self_pipe() has been called or even while it is |
| 145 | # running. Guard for self._csock being None or closed. When |
| 146 | # a socket is closed, send() raises OSError (with errno set to |
| 147 | # EBADF, but let's not rely on the exact error code). |
| 148 | csock = self._csock |
| 149 | if csock is None: |
| 150 | return |
| 151 | |
| 152 | try: |
| 153 | csock.send(b'\0') |
| 154 | except OSError: |
| 155 | if self._debug: |
| 156 | logger.debug("Fail to write a null byte into the " |
| 157 | "self-pipe socket", |
| 158 | exc_info=True) |
| 159 | |
| 160 | def _start_serving(self, protocol_factory, sock, |
| 161 | sslcontext=None, server=None, backlog=100, |