Distributed self-replicating programs in Python
Go to file
Alex Willmer 598de81143 mitogen: Fix subprocess ResourceWarning
Python 3.x emits `ResourceWarning`s if certains resources aren't correctly
closed. Due to the way Mitogen has been terminating child processes this has
been occurring.

```
test_dev_tty_open_succeeds
(create_child_test.TtyCreateChildTest.test_dev_tty_open_succeeds) ...
/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/subprocess.py:1127:
ResourceWarning: subprocess 3313 is still running
  _warn("subprocess %s is still running" % self.pid,
ResourceWarning: Enable tracemalloc to get the object allocation traceback
ok
```

During garbage collection subprocess.Popen() objects emit
ResourceWarning("subprocess 123 is still running")
if proc.returncode hasn't been set. Typically calling proc.wait() does so,
once the sub-process has exited. Calling os.waitpid(proc.pid, 0) also waits
for the sub-process to exit, but it doesn't update proc.returncode, so the
ResourceWarning is still emitted.

This change exposes `subprocess.Popen` methods on
`mitogen.parent.PopenProcess`, so that the returncode can be set.

See https://gist.github.com/moreati/b8d157ff82cb15234bece4033accc5e5
2024-09-10 16:02:49 +01:00
.ci ci: Drop macOS Python 3.12 + Ansible 9 tests 2024-09-06 21:43:43 +01:00
.github chore: Add issue templates for 0.2 vs 0.3 releases 2021-02-09 21:35:14 +00:00
ansible_mitogen patch #509 : ansible_ssh_common_args issues 2024-09-05 15:03:01 +01:00
docs tests: Test templating of ansible_ssh_common_args et al 2024-09-06 11:51:58 +01:00
examples Replace os.system() with subprocess.check_call() 2022-04-21 20:19:51 +01:00
mitogen mitogen: Fix subprocess ResourceWarning 2024-09-10 16:02:49 +01:00
scripts add Python3 compatibility 2024-04-04 15:23:06 +01:00
tests mitogen: Fix subprocess ResourceWarning 2024-09-10 16:02:49 +01:00
.gitignore Ignore Ansible retry files 2024-03-04 13:38:09 +00:00
.lgtm.yml Whoops, merge together lgtm.yml and .lgtm.yml 2019-08-13 10:16:41 +01:00
LICENSE Bump copyright year and use generic author name (testing Travis) 2021-01-14 20:07:47 +00:00
MANIFEST.in setup.py: include LICENSE; closes #538. 2019-02-12 16:15:52 +00:00
README.md Abandon Travis CI We have no credits, and its a PITA to maintain two CI platforms. The tests running on Travis provide very little extra coverage vs Azure Pipelines alone 2021-10-20 02:03:12 +01:00
dev_requirements.txt Split dev_requirements.txt up according to test mode. 2018-11-06 17:00:17 +00:00
preamble_size.py mitogen.parent: Remove tabs from minimized first stage 2021-11-18 18:40:19 +00:00
run_tests tests: Remove unittest2, use stdlib unittest 2022-04-20 17:54:12 +01:00
setup.cfg Declare universal wheel support 2021-01-27 20:19:56 +00:00
setup.py mitogen: Support Python 3.12 2024-03-17 14:58:02 +00:00
tox.ini tests: Unpin versions of Ansible 2.10, 3, & 4 2024-09-06 15:57:08 +01:00

README.md