Message307752
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. |
|
Date |
User |
Action |
Args |
2017-12-06 16:48:07 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, barry, ncoghlan, r.david.murray, yselivanov, sblondon |
2017-12-06 16:48:07 | serhiy.storchaka | set | messageid: <1512578887.23.0.213398074469.issue32234@psf.upfronthosting.co.za> |
2017-12-06 16:48:07 | serhiy.storchaka | link | issue32234 messages |
2017-12-06 16:48:07 | serhiy.storchaka | create | |
|