From 6b67d60194eeedb91ed4fe2dc0b741601be6a5e4 Mon Sep 17 00:00:00 2001 From: Peter Saveliev Date: Mon, 24 Jun 2024 13:26:09 +0200 Subject: [PATCH] core: fix default queues --- pyroute2/netlink/core.py | 5 +++-- pyroute2/plan9/client.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pyroute2/netlink/core.py b/pyroute2/netlink/core.py index 4a67ac282..b788541c8 100644 --- a/pyroute2/netlink/core.py +++ b/pyroute2/netlink/core.py @@ -57,7 +57,8 @@ async def get(self, tag): return ret async def put(self, tag, message): - self.ensure(tag) + if tag not in self.queues: + tag = 0 return await self.queues[tag].put(message) def ensure(self, tag): @@ -66,7 +67,7 @@ def ensure(self, tag): def put_nowait(self, tag, message): if tag not in self.queues: - self.queues[tag] = asyncio.Queue() + tag = 0 return self.queues[tag].put_nowait(message) diff --git a/pyroute2/plan9/client.py b/pyroute2/plan9/client.py index 311776fba..4fb8652cf 100644 --- a/pyroute2/plan9/client.py +++ b/pyroute2/plan9/client.py @@ -38,8 +38,9 @@ def request(self, msg, tag=0): msg['header']['tag'] = tag msg.reset() msg.encode() + self.socket.msg_queue.ensure(tag) self.socket.send(msg.data) - return tuple(self.socket.get(msg_seq=tag))[0] + return tuple(self.socket.get(msg_seq=0))[0] finally: self.socket.addr_pool.free(tag, ban=0xFF)