This project implements a backport of the PEP 567 contextvars module from Python 3.7 for Python 3.5+. It is a full implementation of the original contextvars module with the same features.
Installation is very easy. Either install it from PyPI or directly from GitHub:
$ pip3 install -U better-contextvars $ pip3 install -U git+https://github.com/itsVale/better-contextvars#egg=better-contextvars $ git clone https://github.com/itsVale/better-contextvars $ python3 setup.py install
As stated above, this is an exact representation of the original contextvars module. Because of that, it is totally fine to use the official documentation for contextvars.
PEP 567 provides a comprehensive overview of the API.
You use it the same way as the original module.
import better_contextvars as contextvars
var = contextvars.ContextVar('test')
...
For more usage examples, have a look at tests.
If you decide to contribute, please always lint your code. The preferred linter is pylama.