crossbario / crossbario/autobahn-python

Component.start() - loop argument is not propagated properly

Open
#1,069 9 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

asyncio needs-investigation Python 3
Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

Consider the following:

import asyncio
from autobahn.asyncio.component import Component

comp = Component()
loop = asyncio.new_event_loop()
f = comp.start(loop=loop)
print("passed loop id = ", id(loop))
print("retruned loop id = ", id(f._loop))
print("default loop id = ", id(asyncio.get_event_loop()))

Which results in

passed loop id =  140480361130696
retruned loop id =  140480298199416
default loop id =  140480298199416

I.e. somewhere down the road, Autobahn falls back to use the default loop.

It breaks on us while trying to run tests using asynctest module which tries to provide isolated loop for each test. For now we get away with setting use_default_loop to False, which is not ideal of course.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in autobahn.asyncio.component at Component.start() and trace how the supplied loop reaches the returned future. Reproduce the issue with the Python snippet and compare f._loop with the explicitly passed loop and the default loop. Done means the returned future uses the loop passed to Component.start(), including when isolated asynctest loops are used.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.