Repository navigation
Clean file descriptor and memory leaks - #1317
Conversation
|
@pitrou if you have a moment can you take a look at the failures in travis for this PR? We're getting out of memory errors on master when forking new processes. |
|
It looks like we're leaking file descriptors |
| @classmethod | ||
| def _watch_process(cls, selfref, process, state, q): | ||
| r = repr(selfref()) | ||
| while True: |
There was a problem hiding this comment.
Is there a good reason to poll here instead of simply waiting for the exit with process.join?
There was a problem hiding this comment.
We now use process.join after we poll for when the process starts. We could probably do this more cleanly, but I'm going to punt for now.
| pass | ||
| while True: | ||
| # Periodic poll as there's no simple way to poll a threading Queue | ||
| # and a mp Process at the same time. |
There was a problem hiding this comment.
This comment is now obsolete, no?
|
There is a method, I assume the poll for process start is because you can't A more straightforward architecture to analyse would be to start the process watcher thread once My suggestion would be to move the |
|
I've removed |
| _process_one_message(timeout=1e6) | ||
| except SystemExit: | ||
| return | ||
| q.put({'op': 'stop'}) |
There was a problem hiding this comment.
So what happens if e.g. someone calls terminate after the process has stopped and you have stopped the message queue thread?
There was a problem hiding this comment.
I don't immediately see an issue here. All {'op': 'stop'} does is stop the message queue thread, so this wouldn't have a large impact. You know this part of the code better than I do though. If you see something amiss then please speak up.
| r = repr(selfref()) | ||
| process.join() | ||
| exitcode = process.exitcode | ||
| if exitcode is not None: |
There was a problem hiding this comment.
This should always be true after join(), so you can turn this into an assert.
| state.exitcode = exitcode | ||
| # Make sure the process is removed from the global list | ||
| # (see _children in multiprocessing/process.py) | ||
| process.join(timeout=0) |
There was a problem hiding this comment.
join() was already called above, so it's pointless to call it again :-)
|
|
||
| thread = threading.Thread( | ||
| target=AsyncProcess._watch_process, | ||
| name="AsyncProcess %s watch" % name, |
There was a problem hiding this comment.
Would be nice to have a slightly different name for the two auxiliary threads :-)
|
I took a brief look at the AsyncProcess changes (see comments). |
We did a hasty merge in dask#1317 . This includes a few follow on changes.
We did a hasty merge in dask#1317 . This includes a few follow on changes.
* Clean up AsyncProcess handling We did a hasty merge in #1317 . This includes a few follow on changes. * add failing test * remove {'op': 'stop'} message
No description provided.