reactor: Add explicit finalize() method to clean up reactor state
The existence of a __del__() method prevents deallocation on python2 if there are circular references. Replace the __del__() method with a new finalize() call and arrange for it to be called when the main reactor is released. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -178,11 +178,6 @@ class SelectReactor:
|
||||
util.set_nonblock(self._pipe_fds[0])
|
||||
util.set_nonblock(self._pipe_fds[1])
|
||||
self.register_fd(self._pipe_fds[0], self._got_pipe_signal)
|
||||
def __del__(self):
|
||||
if self._pipe_fds is not None:
|
||||
os.close(self._pipe_fds[0])
|
||||
os.close(self._pipe_fds[1])
|
||||
self._pipe_fds = None
|
||||
# Greenlets
|
||||
def _sys_pause(self, waketime):
|
||||
# Pause using system sleep for when reactor not running
|
||||
@@ -251,6 +246,11 @@ class SelectReactor:
|
||||
g_next.switch()
|
||||
def end(self):
|
||||
self._process = False
|
||||
def finalize(self):
|
||||
if self._pipe_fds is not None:
|
||||
os.close(self._pipe_fds[0])
|
||||
os.close(self._pipe_fds[1])
|
||||
self._pipe_fds = None
|
||||
|
||||
class PollReactor(SelectReactor):
|
||||
def __init__(self):
|
||||
|
||||
Reference in New Issue
Block a user