autobahn-python
autobahn-python copied to clipboard
Unhandled exception when closing ssl connection with SIGINT
I use typical setup with
from autobahn.asyncio.component import Component, run
comp = Component(...)
run([comp])
where connection is over "wss://" protocol.
When hitting Ctrl+C (sending SIGINT) this is what happens:
^C2018-03-29T11:12:48 Shutting down due to SIGINT
2018-03-29T11:12:48 Fatal write error on socket transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x7f14e1c62978>
transport: <_SelectorSocketTransport fd=6>
Traceback (most recent call last):
File "/usr/lib64/python3.6/asyncio/selector_events.py", line 761, in write
n = self._sock.send(data)
OSError: [Errno 9] Bad file descriptor
2018-03-29T11:12:48 Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x7f14e1c62978>
transport: <_SelectorSocketTransport closing fd=6>
Traceback (most recent call last):
File "/usr/lib64/python3.6/asyncio/selector_events.py", line 761, in write
n = self._sock.send(data)
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib64/python3.6/asyncio/sslproto.py", line 646, in _process_write_backlog
self._transport.write(chunk)
File "/usr/lib64/python3.6/asyncio/selector_events.py", line 765, in write
self._fatal_error(exc, 'Fatal write error on socket transport')
File "/usr/lib64/python3.6/asyncio/selector_events.py", line 645, in _fatal_error
self._force_close(exc)
File "/usr/lib64/python3.6/asyncio/selector_events.py", line 657, in _force_close
self._loop.call_soon(self._call_connection_lost, exc)
File "/usr/lib64/python3.6/asyncio/base_events.py", line 574, in call_soon
self._check_closed()
File "/usr/lib64/python3.6/asyncio/base_events.py", line 357, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
you can find this also in #925
The whole traceback does not contain any references to Autobahn, only the Python stdlib. mmh .. is that an asyncio bug? trying to write to a closed SSL during closing ..
I think what happens is: the CPy code https://github.com/python/cpython/blob/9b21856b0fcda949de239edc7aa6cf3f2f4f77a3/Lib/asyncio/selector_events.py#L864 does not handle a loss of the FD, tries to still send (even though the connection and FD is gone), and consequently runs into an OSError
(Bad file descriptor)
If that is true, the bug is in CPy ..
Known issue in CPy: https://bugs.python.org/issue36709
Thanks for the info! so yeah, it's an upstream issue (filed 2 days after my comment, so we couldn't know)