A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-July/054843.html below:

[Python-Dev] Possible context managers in stdlib

[Python-Dev] Possible context managers in stdlib [Python-Dev] Possible context managers in stdlibMichael Chermside mcherm at mcherm.com
Mon Jul 11 20:19:14 CEST 2005
I 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.

Nick Coghlan replies:
> 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.

I don't think that would be desirable. These things CAN be useful in a
multi-threaded program if you know what you're doing. One common example
would be to use them only from the main thread.

-- Michael Chermside

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4