aiowerkzeug
Library to make werkzeug working with asyncio.
Changelog
Version 0.2.0
- Use Python 3.5 async syntax.
- New :func:`~keep_context_factory`. It works like :func:`~context_coroutine`, but simple code.
- Async version of Local, LocalStack and LocalManager. They implement __release_local__ method.
Features
-
Async versions of Local, LocalStack and LocalManager.
-
Locals work on asyncio Tasks. :class:`werkzeug.local.Local` or :class:`werkzeug.local.LocalStack` must be patched with :func:`aiowerkzeug.local.patch_local`
Patched :class:`werkzeug.local.Local` or :class:`werkzeug.local.LocalStack` use current :class:`asyncio.tasks.Task` to determine context.
-
Decorator factory to mark coroutines to run in a context. Useful for Flask. It allows to run corountines in new :class:`asyncio.tasks.Task` inside a specific context.
For example, in Flask to run coroutines in Application context it is possible to create a decorator like that:
def _get_app_context(): return current_app.app_context() app_coroutine = partial(context_coroutine, ctx=_get_app_context) @app_coroutine def foo_bar(): print(current_app.debug) @flask_app.route('/') def caller(): asyncio.ensure_future(foo_bar())
-
Asyncio HTTP server runner with reload
$ python aiowerkzeug/serving.py --reload app_test.app
TODO
- Form parser
- Debug middleware
- Static files middleware