Skip to content

Conversation

@hetelek
Copy link
Contributor

@hetelek hetelek commented Nov 25, 2020

This is needed to properly handle asyncio timeouts. If the future is already done, then set_exception will raise an exception and the self.bus._finalize call will not be reached.

I ran into this failure mode when wrapping bus.call in asyncio.wait_for:
await asyncio.wait_for(bus.call(...), timeout=10)

If the timeout was reached, it would cause an infinite loop of errors:

Traceback (most recent call last):
  File "asyncio/events.py", line 127, in _run
  File "site-packages/dbus_next/aio/message_bus.py", line 63, in write_callback
asyncio.base_futures.InvalidStateError: invalid state
2020-11-25 12:05:01,578 - asyncio - ERROR - Exception in callback _MessageWriter.write_callback()
handle: <Handle _MessageWriter.write_callback()>
Traceback (most recent call last):
  File "site-packages/dbus_next/aio/message_bus.py", line 51, in write_callback
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

...

This is needed to properly handle asyncio timeouts. If the
future is already done, then set_exception will raise an
exception and the `self.bus._finalize` call will not be reached.
@acrisci
Copy link
Member

acrisci commented Nov 25, 2020

👍

@acrisci acrisci merged commit f54e2c5 into altdesktop:master Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants