mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 09:39:25 +01:00
test-runner: fix process cleanup
Processes which were not explicitly killed ended up staying around forever because they internally held references to other objects such as GLib IO watches or write FDs. This shuffles some code so these objects get cleaned up both when explititly killed and after being waited for.
This commit is contained in:
parent
920dc5b087
commit
165557070e
@ -287,7 +287,23 @@ class Process(subprocess.Popen):
|
|||||||
# Override wait() so it can do so non-blocking
|
# Override wait() so it can do so non-blocking
|
||||||
def wait(self, timeout=10):
|
def wait(self, timeout=10):
|
||||||
Namespace.non_block_wait(self.__wait, timeout, 1)
|
Namespace.non_block_wait(self.__wait, timeout, 1)
|
||||||
|
self._cleanup()
|
||||||
|
|
||||||
|
def _cleanup(self):
|
||||||
|
if self.cleanup:
|
||||||
|
self.cleanup()
|
||||||
|
|
||||||
|
self.write_fds = []
|
||||||
|
|
||||||
|
if self.io_watch:
|
||||||
|
GLib.source_remove(self.io_watch)
|
||||||
|
self.io_watch = None
|
||||||
|
|
||||||
|
self.cleanup = None
|
||||||
|
self.killed = True
|
||||||
|
|
||||||
|
if self in self.ctx.processes:
|
||||||
|
self.ctx.processes.remove(self)
|
||||||
# Override kill()
|
# Override kill()
|
||||||
def kill(self, force=False):
|
def kill(self, force=False):
|
||||||
if self.killed:
|
if self.killed:
|
||||||
@ -306,20 +322,7 @@ class Process(subprocess.Popen):
|
|||||||
dbg("Process %s did not complete in 15 seconds!" % self.name)
|
dbg("Process %s did not complete in 15 seconds!" % self.name)
|
||||||
super().kill()
|
super().kill()
|
||||||
|
|
||||||
if self.cleanup:
|
self._cleanup()
|
||||||
self.cleanup()
|
|
||||||
|
|
||||||
self.write_fds = []
|
|
||||||
|
|
||||||
if self.io_watch:
|
|
||||||
GLib.source_remove(self.io_watch)
|
|
||||||
self.io_watch = None
|
|
||||||
|
|
||||||
self.cleanup = None
|
|
||||||
self.killed = True
|
|
||||||
|
|
||||||
if self in self.ctx.processes:
|
|
||||||
self.ctx.processes.remove(self)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.args) + '\n'
|
return str(self.args) + '\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user