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/2013-October/129670.html below:

[Python-Dev] On suppress()'s trail blazing (was Re: cpython: Rename contextlib.ignored() to contextlib.ignore())

[Python-Dev] On suppress()'s trail blazing (was Re: cpython: Rename contextlib.ignored() to contextlib.ignore())Stefan Krah stefan at bytereef.org
Thu Oct 17 22:05:24 CEST 2013
Xavier Morel <python-dev at masklinn.net> wrote:
> On 2013-10-17, at 20:55 , Oscar Benjamin wrote:
> > On 17 October 2013 19:40, Xavier Morel <python-dev at masklinn.net> wrote:
> >> I think there's already a significant split between context managers
> >> which handle the lifecycle of a local resource (file, transaction) and
> >> those which purport to locally alter global-ish state (cwd,
> >> decimal.localcontext, logging.captureWarnings, redirect_stdout).

Well, naming is difficult.  In the case of decimal it's a temporary global
but also thread-local context.


> You have to know which contextmanagers to what and how, and avoid them
> in these specific situations. I'm really bothered by these being unsafe
> by default. Technically they're already broken but the chance of them
> being used in such a context are low, whereas it wouldn't be unexpected
> for a user to e.g. create a local decimal context in a coroutine and
> *not* expect that local context to affect other coroutines running
> concurrently.

I don't think localcontext() is broken. The fine manual is quite clear
that "current contexts" are per thread. The localcontext() docs explicitly
say that the "current context" is swapped.


Of course there are multiple ways to use individual contexts for each
coroutine. Use the context methods or pass the context to the Decimal
methods.



Stefan Krah


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