[Python-Dev] Possible context managers in stdlib
Nick Coghlan
ncoghlan at gmail.com
Sat Jul 9 03:04:53 CEST 2005
Michael Chermside wrote:
> I agree with Barry. Not only should they be in the stdlib, but they
> should have very clear warnings in their docstrings and other documentation
> that state that they are ONLY safe to use in single-threaded programs.
>
> This achieves two things: it makes them available to those who need
> them (not everyone uses threads!), and it rather forcefully makes the
> point that it's NOT usually a good idea to modify global state info in
> a context manager because doing so is not generally threadsafe.
Wouldn't they be able to actually emit a warning at run-time if they're used
in a multi-threaded program? That would be even better motivation for
including them, IMO.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.blogspot.com
More information about the Python-Dev
mailing list