Fix memory leak when destroying libev connections

The IO objects held a reference to their LibevConnection instances
through the callback.  This reference cycle was preventing the
connection from being garbage collected.

Fixes #93
This commit is contained in:
Tyler Hobbs
2014-06-10 14:45:38 -05:00
parent 882fffb463
commit d0e040d7dd
2 changed files with 6 additions and 0 deletions

View File

@@ -12,6 +12,8 @@ Bug Fixes
with shared state when using multiprocessing (PYTHON-60)
* Add python-six to debian dependencies, move python-blist to
recommends
* Fix memory leak when libev connections are created and
destroyed (github #93)
2.0.1
=====

View File

@@ -187,8 +187,12 @@ class LibevLoop(object):
for conn in to_stop:
if conn._write_watcher:
conn._write_watcher.stop()
# clear reference cycles from IO callback
del conn._write_watcher
if conn._read_watcher:
conn._read_watcher.stop()
# clear reference cycles from IO callback
del conn._read_watcher
changed = True