New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio: recv_into() must not return b'' if the socket/pipe is closed #85639
Comments
The proactor event loop of asyncio returns b'' on recv_into() if the socket/pipe is closed: def recv_into(self, conn, buf, flags=0):
...
try:
...
except BrokenPipeError:
return self._result(b'')
... But a socket recv_into() must always return a number: the number of written bytes. Example with socket.socket.recv_into() method: IMHO zero must be returned here. This bug may be the root cause of bpo-38912 bug. Attached PR fix the issue. |
The function was added in 2017 in bpo-31819, PR 4051: commit 525f40d
|
Yeah, very likely. This bug makes asyncio inconsistent. A transport is "not closed" and "closed" at the same time... C:\vstinner\python\master\lib\asyncio\proactor_events.py:121: ResourceWarning: unclosed transport <_ProactorReadPipeTransport> Warning -- Unraisable exception
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001F30C938EB0>
Traceback (most recent call last):
File "C:\vstinner\python\master\lib\asyncio\proactor_events.py", line 122, in __del__
self.close()
File "C:\vstinner\python\master\lib\asyncio\proactor_events.py", line 114, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\vstinner\python\master\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\vstinner\python\master\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: