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

[WIP] Feature to avoid hang procs #46

Closed
wants to merge 4 commits into from

Conversation

schipiga
Copy link

@schipiga schipiga commented Dec 5, 2019

Hello @noxdafox ,

As I mentioned some time ago, working with ProcessPool made some headache for me due to hang & zombie processes. And this patch solved it in my case:

import os
import time

from pebble import ProcessPool


def main():
    pid = os.fork()


pool = ProcessPool(max_workers=1)
with pool:
    pool.schedule(main)
time.sleep(10)

launch:

root@99085a9eeb5f:/# python proba.py&
[1] 1432

observe launched processes:

root@99085a9eeb5f:/# ps aux|grep python
root      1432  1.2  0.1 243732 16228 pts/0    S    09:10   0:00 python proba.py
root      1437  0.0  0.1  22432  9668 pts/0    S    09:10   0:00 python proba.py
root      1439  0.0  0.0   4832   892 pts/0    S+   09:10   0:00 grep python

observe after 10 sec:

root@99085a9eeb5f:/# ps aux|grep python
root      1437  0.0  0.1  22432  9668 pts/0    S    09:10   0:00 python proba.py
root      1441  0.0  0.0   4832   892 pts/0    S+   09:11   0:00 grep python
[1]+  Done                    python proba.py

let's see, what it waits for:

root@99085a9eeb5f:/# strace -p 1437
strace: Process 1437 attached
select(4, [3], [], [], NULL

As I understand, something wrong happens, because it forked after fork, which had lead to descriptors communication problem.

@schipiga schipiga changed the title Feature to avoid hang procs [WIP] Feature to avoid hang procs Dec 5, 2019
@schipiga schipiga changed the title [WIP] Feature to avoid hang procs Feature to avoid hang procs Dec 5, 2019
@schipiga schipiga force-pushed the feature/avoid-hang-procs branch 6 times, most recently from 5cd95cf to a391e27 Compare December 5, 2019 21:50
@schipiga schipiga changed the title Feature to avoid hang procs [WIP] Feature to avoid hang procs Dec 6, 2019
@schipiga
Copy link
Author

schipiga commented Dec 6, 2019

not ready yet

@schipiga schipiga closed this Dec 6, 2019
@noxdafox
Copy link
Owner

noxdafox commented Dec 6, 2019

Hello,

Before submitting a PR I would recommend you to open one or more issue tickets where you state the problems and how to reproduce them.

The second example is expected behaviour and not a problem of the Pool. The Pool is responsible of it's own resources and not of the resources created by the workers.

If a worker spawns a process or creates a file, it should take care of removing them itself.

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

Successfully merging this pull request may close these issues.

None yet

2 participants