Skip to content

Commit

Permalink
core: fix default queues
Browse files Browse the repository at this point in the history
  • Loading branch information
svinota committed Jun 24, 2024
1 parent ca9ec88 commit 6b67d60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pyroute2/netlink/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)


Expand Down
3 changes: 2 additions & 1 deletion pyroute2/plan9/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 6b67d60

Please sign in to comment.