BUG: Pool not closing pipes after close and join
@gautamp8 is already working on this.
Since Feb 28, 2021.
Assessment
This issue has not been assessed yet.
Description
I'm using billiard.Pool to run parallel computations.
I have a continuous service (celery) doing it and after a while I get an OSError 24 ("Too many open files").
While debugging I found that a Pool creates a number of pipes:
in pool.py while doing _setup_queues()
self._inqueue = self._ctx.SimpleQueue() # creates 2 pipes
self._outqueue = self._ctx.SimpleQueue() # creates 2 pipes
and then 2 for each process in the Pool.
When joining, it closes pipes for each of the process but not 4 for _inqueue and _outqueue.
Those become open forever till the MAIN process is closed.
Code to reproduce:
import billiard as mp
import os
def f(a):
return a + 1
if __name__ == '__main__':
pid = os.getpid()
get_number_of_conns = os.popen(f'ls -l /proc/{pid}/fd | wc -l').read()
print(f'At the beginning we only have {get_number_of_conns.strip()} connections')
for i in range(10):
# creating a pool
pool = mp.Pool(mp.cpu_count() - 1)
# running a job
result = pool.map(f, range(5))
# closing the pool and joining
pool.close()
pool.join()
# getting number of open connections
get_number_of_conns = os.popen(f'ls -l /proc/{pid}/fd | wc -l').read()
print(f'Open connections: {get_number_of_conns.strip()}')
- Dominant language
- Python
- Stars
- 436
- Forks
- 273
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 5
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from celery/billiard
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
return in finally can swallow exceptionsMay be free again @auvipy claimed this 602 days ago, and no pull request is open. Open
celery/billiard#414 · 6 comments · 3 reactions · 1 assignee ·
-
Handling numpyOpen
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
AI bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AUTO-MAS-Project/AUTO-MAS#1960 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
btclib-org/btclib-wallet#872 ·
Maintainers usually reply within 1 day
-
[Bug]: Scheduled returns scan all accepted minion keys causing extreme loadPossibly taken A pull request linked to this issue is open or already merged. Openbug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
saltstack/salt#70789 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
btclib-org/btclib#3093 ·
Maintainers usually reply within 1 day