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 serhiy.storchaka
Recipients barry, ncoghlan, r.david.murray, sblondon, serhiy.storchaka, yselivanov
Date 2017-12-06.16:48:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1512578887.23.0.213398074469.issue32234@psf.upfronthosting.co.za>
In-reply-to
Content
There is an ambiguity. What should the context manager do? Should it call a close() on exit (as the OP implies)? Or call lock() on enter and unlock() on exit as in Barry's example? Both behaviors look reasonable.

"In the face of ambiguity, refuse the temptation to guess" and "Explicit is better than implicit". This is perhaps the reason why this feature is not implemented yet. Perhaps there were discussions about this in the past.

contextlib.closing() can be used for explicit requesting the first behavior. Maybe it's a time to add contextlib.locked() or something like.
History
Date User Action Args
2017-12-06 16:48:07serhiy.storchakasetrecipients: + serhiy.storchaka, barry, ncoghlan, r.david.murray, yselivanov, sblondon
2017-12-06 16:48:07serhiy.storchakasetmessageid: <1512578887.23.0.213398074469.issue32234@psf.upfronthosting.co.za>
2017-12-06 16:48:07serhiy.storchakalinkissue32234 messages
2017-12-06 16:48:07serhiy.storchakacreate