This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mrknmc
Recipients mrknmc
Date 2018-03-18.16:41:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521391273.18.0.467229070634.issue33097@psf.upfronthosting.co.za>
In-reply-to
Content
Currently, one can submit a task to an executor (both ThreadPoolExecutor and ProcessPoolExecutor) during interpreter shutdown. One way to do this is to register function fun with atexit as below.

@atexit.register
def fun():
   pool.submit(print, "apple")

The future is accepted and goes into PENDING state. However, this can cause issues if the _python_exit function (located in concurrent/futures/thread.py and/or concurrent/futures/process.py) executes before function fun.

Function _python_exit will shutdown the running workers in the pool and hence there will be no workers running by the time fun is executed so the future will be left in PENDING state forever.

The solution submitted here is to instead raise a RuntimeException when a task is submitted during interpreter shutdown. This is the same behaviour as when the shutdown method of an executor is called explicitly.
History
Date User Action Args
2018-03-18 16:41:13mrknmcsetrecipients: + mrknmc
2018-03-18 16:41:13mrknmcsetmessageid: <1521391273.18.0.467229070634.issue33097@psf.upfronthosting.co.za>
2018-03-18 16:41:13mrknmclinkissue33097 messages
2018-03-18 16:41:13mrknmccreate