Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion removing errors concerning process management #24

Open
BitFis opened this issue Nov 23, 2020 · 0 comments
Open

Suggestion removing errors concerning process management #24

BitFis opened this issue Nov 23, 2020 · 0 comments

Comments

@BitFis
Copy link

BitFis commented Nov 23, 2020

While using cirque I ran into some warnings concerning process management:

/usr/lib/python3.8/subprocess.py:942: ResourceWarning: subprocess 28203 is still running
  _warn("subprocess %s is still running" % self.pid,
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/lib/python3.8/subprocess.py:942: ResourceWarning: subprocess 28202 is still running
  _warn("subprocess %s is still running" % self.pid,
ResourceWarning: Enable tracemalloc to get the object allocation traceback
cirque/connectivity/socatpipepair.py:48: ResourceWarning: unclosed file <_io.BufferedReader name=3>
  self.socat = None
ResourceWarning: Enable tracemalloc to get the object allocation traceback

Following changes would fix it. Feel free to use them as you feel fit:

diff --git a/cirque/connectivity/socatpipepair.py b/cirque/connectivity/socatpipepair.py
index 2b64149..c3c2c38 100644
--- a/cirque/connectivity/socatpipepair.py
+++ b/cirque/connectivity/socatpipepair.py
@@ -45,6 +45,8 @@ class SocatPipePair:
     def close(self):
         if self.socat is not None:
             self.socat.terminate()
+            self.socat.wait()
+            self.socat.stderr.close()
         self.socat = None

     def __del__(self):
diff --git a/cirque/connectivity/threadsimpipe.py b/cirque/connectivity/threadsimpipe.py
index 02de636..6ad360f 100644
--- a/cirque/connectivity/threadsimpipe.py
+++ b/cirque/connectivity/threadsimpipe.py
@@ -64,6 +64,7 @@ class ThreadSimPipe:
             self.radio_fd = None
         if self.radio_process is not None:
             self.radio_process.terminate()
+            self.radio_process.wait()
             self.radio_process = None
         if self._socat_pipe is not None:
             self._socat_pipe.close()

Thanks and regards

@BitFis BitFis changed the title Suggestion removing errors concir Suggestion removing errors concerning process management Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant