crossbario / crossbario/autobahn-python
Cancellation of the handlers set to the "ready" event of an asyncio component are not properly handled
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 768
- PR merge metrics
- No merged PRs in 30d
Description
After cancelling the handlers associated with the "ready" event a _GatheringFuture exception holding the CancelledError is raised but never retrieved.
@comp.on_ready
async def go(*args, **kwargs):
while True:
await asyncio.sleep(1)
run(comp)
gives, after the user initiated a shutdown:
2019-02-22T16:54:47 connecting once using transport type "websocket" over endpoint "tcp"
2019-02-22T16:54:50 Shutting down due to SIGINT
2019-02-22T16:54:50 _GatheringFuture exception was never retrieved
future: <_GatheringFuture finished exception=CancelledError()>
concurrent.futures._base.CancelledError
Just await the handlers solves the issue:
# in autobahn.util.ObservableMixin.fire
for handler in self._listener
future = txaio.as_future(
def consume_result(fut):
return fut.result()
future.add_callbacks(consume_result)
res.append(future)
Related to #1000
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in autobahn.util.ObservableMixin.fire and reproduce the reported asyncio component shutdown with the ready-handler example. Trace how cancelled handlers and the _GatheringFuture are handled during SIGINT shutdown. Done means cancellation no longer leaves an un-retrieved exception while the handlers still shut down correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100