Fix same named actor race

When an actor has already been registered with the arbiter it should
exist in the registry and thus the wait event should have been removed.
Check that the registry indeed holds an event before clearing it.
multi_program_tests
Tyler Goodlet 2018-09-08 09:40:35 -04:00
parent 6b8393a4d6
commit ee7959cb55
1 changed files with 2 additions and 1 deletions

View File

@ -668,7 +668,8 @@ class Arbiter(Actor):
events = self._waiters.pop(name, ()) events = self._waiters.pop(name, ())
self._waiters.setdefault(name, []).append(uid) self._waiters.setdefault(name, []).append(uid)
for event in events: for event in events:
event.set() if isinstance(event, trio.Event):
event.set()
def unregister_actor(self, uid: Tuple[str, str]) -> None: def unregister_actor(self, uid: Tuple[str, str]) -> None:
self._registry.pop(uid, None) self._registry.pop(uid, None)