mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-05 21:14:05 -06:00
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:
parent
a3fa11ffd4
commit
760a0f8df5
2 changed files with 10 additions and 8 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue