aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/reactor.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-09-16 12:15:19 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-09-16 23:53:45 -0400
commit760a0f8df538ecce87812004ecea73e0db95d99b (patch)
tree4fcebbe13d59f8d7a6a889a68a80a1758cc3cd8b /klippy/reactor.py
parenta3fa11ffd454d6efec414646213eccd3a8525165 (diff)
downloadkutter-760a0f8df538ecce87812004ecea73e0db95d99b.tar.gz
kutter-760a0f8df538ecce87812004ecea73e0db95d99b.tar.xz
kutter-760a0f8df538ecce87812004ecea73e0db95d99b.zip
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>
Diffstat (limited to 'klippy/reactor.py')
-rw-r--r--klippy/reactor.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/klippy/reactor.py b/klippy/reactor.py
index 07c7db19..e38d4fd9 100644
--- a/klippy/reactor.py
+++ b/klippy/reactor.py
@@ -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):