A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-June/054193.html below:

[Python-Dev] PEP 343 - next steps

[Python-Dev] PEP 343 - next steps [Python-Dev] PEP 343 - next stepsPhillip J. Eby pje at telecommunity.com
Mon Jun 13 18:40:02 CEST 2005
At 10:40 PM 6/13/2005 +1000, Nick Coghlan wrote:
>Hmm, you're right. Also, given implementation of PEP 343, code which
>genuinely has to care about this can do so manually:
>
>    with async_exceptions_blocked():
>        with critical_resource():
>            with async_exceptions_unblocked():
>                # Do the real work
>
>This ensures acquisition of the critical resource is not interrupted.
>Even better, the above can be wrapped up in a template and still give
>the desired guarantees:
>
>    @stmt_template
>    def safe_acquisition(resource):
>        with async_exceptions_blocked():
>            with resource():
>                with async_exceptions_unblocked():
>                    yield None
>
>
>    with safe_acquisition(critical_resource):
>        # Do the real work

Ow.  My head hurts.  :)  Seriously, though, wouldn't it make more sense to 
put the 'with async_exceptions_blocked()' in the __init__ or __enter__ of 
'critical_resource'?  Or am I still missing something?

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