bpo-39651: Fix asyncio proactor _write_to_self() (GH-22197) · python/cpython@7dfcc8e (original) (raw)

Original file line number Diff line number Diff line change
@@ -133,14 +133,16 @@ def _write_to_self(self):
133 133 # a socket is closed, send() raises OSError (with errno set to
134 134 # EBADF, but let's not rely on the exact error code).
135 135 csock = self._csock
136 -if csock is not None:
137 -try:
138 -csock.send(b'\0')
139 -except OSError:
140 -if self._debug:
141 -logger.debug("Fail to write a null byte into the "
142 -"self-pipe socket",
143 -exc_info=True)
136 +if csock is None:
137 +return
138 +
139 +try:
140 +csock.send(b'\0')
141 +except OSError:
142 +if self._debug:
143 +logger.debug("Fail to write a null byte into the "
144 +"self-pipe socket",
145 +exc_info=True)
144 146
145 147 def _start_serving(self, protocol_factory, sock,
146 148 sslcontext=None, server=None, backlog=100,