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