Skip to content

Commit 1a5e120

Browse files
committed
explicitly passing in a loop for connection removal
Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
1 parent 281e131 commit 1a5e120

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,4 @@ venv.bak/
111111

112112
# mypy
113113
.mypy_cache/
114+
graph_*.dot

receptor/receptor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ def update_connections(self, protocol_obj, id_=None):
112112
def add_connection(self, protocol_obj):
113113
self.update_connections(protocol_obj)
114114

115-
def remove_connection(self, protocol_obj, id_=None):
115+
def remove_connection(self, protocol_obj, id_=None, loop=None):
116116
if id_ is None:
117117
id_ = protocol_obj.id
118118

119+
if loop is None:
120+
loop = protocol_obj.loop
121+
119122
notify_connections = []
120123
for connection_node in self.connections:
121124
if protocol_obj in self.connections[connection_node]:
@@ -126,7 +129,7 @@ def remove_connection(self, protocol_obj, id_=None):
126129
self.router.debug_router()
127130
self.update_connection_manifest(connection_node)
128131
notify_connections += self.connections[connection_node]
129-
protocol_obj.loop.create_task(self.send_route_advertisement(self.router.get_edges()))
132+
loop.create_task(self.send_route_advertisement(self.router.get_edges()))
130133

131134
async def shutdown_handler(self):
132135
while True:

receptor/ws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def register(self, ws):
5353
self.receptor.update_connections(ws, id_=self.remote_id)
5454

5555
def unregister(self, ws):
56-
self.receptor.remove_connection(ws, id_=self.remote_id)
56+
self.receptor.remove_connection(ws, id_=self.remote_id, loop=self.loop)
5757
self._cancel(self.read_task)
5858
self._cancel(self.handle_task)
5959
self._cancel(self.write_task)

0 commit comments

Comments
 (0)