OpenCyphal / pycyphal

Python implementation of the Cyphal protocol stack.
https://pycyphal.readthedocs.io/
MIT License
117 stars 106 forks source link

Race condition on close #204

Closed pavel-kirienko closed 2 years ago

pavel-kirienko commented 2 years ago
2022-01-10 21:38:54 0601453 ERR pyuavcan.transport.redundant._session._output: RedundantOutputSession(OutputSessionSpecifier(data_specifier=ServiceDataSpecifier(service_id=430, role=<Role.RESPONSE: 2>), remote_node_id=21), PayloadMetadata(extent_bytes=448)): Inferior UnicastCANOutputSession(OutputSessionSpecifier(data_specifier=ServiceDataSpecifier(service_id=430, role=<Role.RESPONSE: 2>), remote_node_id=21), PayloadMetadata(extent_bytes=448)) failed: OSError: [Errno 9] Bad file descriptor
2022-01-10 21:38:54 0601453 ERR pyuavcan.transport.redundant._session._output: RedundantOutputSession(OutputSessionSpecifier(data_specifier=ServiceDataSpecifier(service_id=430, role=<Role.RESPONSE: 2>), remote_node_id=21), PayloadMetadata(extent_bytes=448)): Inferior UnicastCANOutputSession(OutputSessionSpecifier(data_specifier=ServiceDataSpecifier(service_id=430, role=<Role.RESPONSE: 2>), remote_node_id=21), PayloadMetadata(extent_bytes=448)) failed: OSError: [Errno 9] Bad file descriptor
2022-01-10 21:38:54 0601453 ERR asyncio: Future exception was never retrieved
future: <Future finished exception=OSError(9, 'Bad file descriptor')>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/tasks.py", line 432, in wait_for
    await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/redundant/_session/_output.py", line 327, in _inferior_worker_task
    result = await ses.send(wrk.transfer, wrk.monotonic_deadline)
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/_session/_output.py", line 252, in send
    return await self._do_send(can_id, transfer, monotonic_deadline)
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/_session/_output.py", line 163, in _do_send
    if await self._send_handler(transaction):
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/_can.py", line 319, in _do_send
    num_sent = await self._maybe_media.send(
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/media/socketcan/_socketcan.py", line 137, in send
    raise err
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/media/socketcan/_socketcan.py", line 126, in send
    await asyncio.wait_for(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 435, in wait_for
    return fut.result()
  File "/usr/lib/python3.10/asyncio/selector_events.py", line 446, in sock_sendall
    n = sock.send(data)
OSError: [Errno 9] Bad file descriptor
2022-01-10 21:38:54 0601453 ERR asyncio: Future exception was never retrieved
future: <Future finished exception=OSError(9, 'Bad file descriptor')>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/tasks.py", line 432, in wait_for
    await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/redundant/_session/_output.py", line 327, in _inferior_worker_task
    result = await ses.send(wrk.transfer, wrk.monotonic_deadline)
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/_session/_output.py", line 252, in send
    return await self._do_send(can_id, transfer, monotonic_deadline)
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/_session/_output.py", line 163, in _do_send
    if await self._send_handler(transaction):
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/_can.py", line 319, in _do_send
    num_sent = await self._maybe_media.send(
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/media/socketcan/_socketcan.py", line 137, in send
    raise err
  File "/home/pavel/.local/lib/python3.10/site-packages/pyuavcan/transport/can/media/socketcan/_socketcan.py", line 126, in send
    await asyncio.wait_for(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 435, in wait_for
    return fut.result()
  File "/usr/lib/python3.10/asyncio/selector_events.py", line 446, in sock_sendall
    n = sock.send(data)
OSError: [Errno 9] Bad file descriptor
pavel-kirienko commented 2 years ago

Not fixed.