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 neologix
Recipients bquinlan, glangford, neologix, pitrou, vstinner
Date 2014-02-08.12:08:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1391861313.61.0.790037099936.issue20516@psf.upfronthosting.co.za>
In-reply-to
Content
Just a quick comment on the patch: in as_completed(), if the future is cancelled or finished, control is yielded back to the caller with the condition's lock held.
As a general rule, libraries should not yield control to the caller with a lock held, because depending on what the client does, this can lead to a deadlock. 
For example, Future.__repr__() acquires the future's lock: since the current implementation uses a reentrant lock, it won't cause a deadlock if called from the same thread, but it could deadlock e.g. if another thread called a similar method which acquires this lock.
Also, more generally, when you hold an object's lock it's to make sure that it's always seen in a consistent state, and yielding control to the user means that it can potentially see it in an inconsistent state.

See e.g. the excellent "Java Concurrency in Practice", or "Effective Java" for more details.
History
Date User Action Args
2014-02-08 12:08:33neologixsetrecipients: + neologix, bquinlan, pitrou, vstinner, glangford
2014-02-08 12:08:33neologixsetmessageid: <1391861313.61.0.790037099936.issue20516@psf.upfronthosting.co.za>
2014-02-08 12:08:33neologixlinkissue20516 messages
2014-02-08 12:08:33neologixcreate