Skip to content

Commit

Permalink
修复内存泄露
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed Dec 5, 2024
1 parent 79ed1d4 commit 631ea14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions roc/channel_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def close(self, key: int) -> bool:
if chan is None:
return True

del self.channels[key]
return chan.close()

def flush(self):
Expand Down
13 changes: 8 additions & 5 deletions roc/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ async def request(self, request: Request) -> Response:

await self.send(packet)

res = await chan.pop()
if res is False:
raise RequestException("request failed")
try:
res = await chan.pop()
if res is False:
raise RequestException("request failed")

data = json.loads(res)
data = json.loads(res)

return make_response(data)
return make_response(data)
finally:
self.channelManager.close(key)

async def start(self):
reader, writer = await asyncio.open_connection(self.host, self.port)
Expand Down

0 comments on commit 631ea14

Please sign in to comment.