[Web-SIG] [PEP 444] Future- and Generator-Based Async Idea

Alice Bevan–McGregor alice at gothcandy.com
Sun Jan 9 02:16:06 CET 2011


On 2011-01-08 09:00:18 -0800, P.J. Eby said:

> (The next interesting challenge would be to integrate this withGraham's 
> proposal for adding cleanup handlers...)

class MyApplication(object):
    def __init__(self):
        pass # process startup code

    def __call__(self, environ):
        yield None # must be a generator
        pass # request code

    def __enter__(self):
        pass # request startup code

    def __exit(exc_type, exc_val, exc_tb):
        pass # request shutdown code -- regardless of exceptions

We could mandate context managers!  :D  (Which means you can still wrap 
a simple function in @contextmanager.)

	- Alice.




More information about the Web-SIG mailing list