Skip to content

Commit

Permalink
Clean up receive_buffer. Fixes memory leak. (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
agronick authored and jonmzeiset committed Nov 27, 2018
1 parent 298a6ba commit 24fe428
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions channels_redis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ async def receive(self, channel):
except asyncio.CancelledError:
# Ensure all tasks are cancelled if we are cancelled.
# Also see: https://bugs.python.org/issue23859
del self.receive_buffer[channel]
for task in tasks:
if not task.cancel():
assert task.done()
Expand Down Expand Up @@ -433,6 +434,9 @@ async def receive(self, channel):
else:
self.receive_buffer[message_channel].put_nowait(message)
message = None
except:
del self.receive_buffer[channel]
raise
finally:
self.receive_lock.release()

Expand Down

0 comments on commit 24fe428

Please sign in to comment.