crossbario / crossbario/autobahn-python
Behaviour of ObservableMixin when its `off` method is called while its `fire` method is currently iterating over listeners
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 768
- PR merge metrics
- No merged PRs in 30d
Description
Suppose we have two listeners on "close" event.
import txaio
from autobahn.util import ObservableMixin
txaio.use_twisted()
class Foo(ObservableMixin):
def __init__(self):
self.set_valid_events(["someEvent"])
def doSomething(self):
self.fire("someEvent", self)
def listener1(foo):
f.off("someEvent", listener1)
print("listener1 called")
def listener2(foo):
print("listener2 called")
f = Foo()
f.on("someEvent", listener1)
f.on("someEvent", listener2)
f.doSomething()
This will output:
listener1 called
This means, when ObservableMixin off method is called inside listener1,
except for last listeners, then the next listeners (listener2) will never get called.
I think this is because ObservableMixin off method is called while
ObservableMixin fire method is iterating over current listeners of event..
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
Locate ObservableMixin's fire and off implementations and reproduce the issue with the two-listener example from the report. Add a regression test covering a listener removing itself during dispatch; done means the remaining listener is still called.
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
- 35/100