Author vstinner
Recipients vstinner
Date 2018-12-12.23:08:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544656092.37.0.788709270274.issue35477@psf.upfronthosting.co.za>
In-reply-to
Content
On a file, "with file:" fails if it's used a second time:
---
fp = open('/etc/issue')
with fp:
    print("first")
with fp:
    print("second")
---

fails with "ValueError: I/O operation on closed file", because file.__enter__() raises this exception if the file is closed.

I propose to have the same behavior on multiprocessing.Pool.__enter__() to detect when the multiprocessing API is misused.

Anyway, after the first "with pool:" block, the pool becomes unusable to schedule now tasks: apply() raise ValueError("Pool not running") in that case for example.
History
Date User Action Args
2018-12-12 23:08:12vstinnersetrecipients: + vstinner
2018-12-12 23:08:12vstinnersetmessageid: <1544656092.37.0.788709270274.issue35477@psf.upfronthosting.co.za>
2018-12-12 23:08:12vstinnerlinkissue35477 messages
2018-12-12 23:08:12vstinnercreate