bpo-35715: Liberate return value of _process_worker#11514
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
|
Signed the PSF contributor agreement |
| # Liberate the resource as soon as possible, to avoid holding onto | ||
| # open files or shared memory that is not needed anymore | ||
| del call_item | ||
| del r |
There was a problem hiding this comment.
This looks incorrect as this will raise a NameError if the first call to call_item fails because the symbol was never bound.
There was a problem hiding this comment.
@pablogsal thanks for catching that. I've modified to handle this case and do nothing - although I'm not generally a fan of passing in except clauses it seems appropriate here.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
There was a problem hiding this comment.
You just need to delete the result in the else clause of the previous try block unless I am missing something.
|
@pablogsal any other feedback on this one? |
|
Hey @pablogsal, any other feedback or changes needed here? |
|
Sorry for the delay. Please, ping me if I have not landed this this week :) |
|
@pablogsal did you mean to ping you about merging, or did I misunderstand? No need to apologise for the delay, appreciate you taking the time :) |
ProcessPoolExecutor workers will hold the return value of their last task in memory until the next task is received. Since the return value has already been propagated to the parent process's
Futureor else effectively discarded by this point, the memory can be safely released.Simple case to reproduce:
This should be easily addressed by having the worker explicitly
del rafter calling_sendback_resultas it already does this forcall_item.https://bugs.python.org/issue35715