getlogbook / logbook

A cool logging replacement for Python.
http://logbook.readthedocs.org
Other
1.48k stars 165 forks source link

Add experimental support for contextvars. #268

Closed miracle2k closed 5 years ago

miracle2k commented 6 years ago

Python 3.7 has something called contextvars: https://docs.python.org/3/library/contextvars.html They are like thread locals, but are bound to the current asyncio task. Other frameworks, such as trio (https://github.com/python-trio/trio) can (and do) use them as well. I suppose even gevent could use them.

As for as I understand, because they are more fine grained, they are effectively a superset of thread locals as well.

I made some choices here:

I am looking for some feedback, and general guidance as to what is required to get this merged.

miracle2k commented 6 years ago

@vmalloc Do Is it worth working on this? I do believe logbook should support this.

vmalloc commented 6 years ago

@miracle2k I think it is worth it, but unfortunately I have been quite busy recently so had no time to go over it...

matan129 commented 5 years ago

I'm also interested in this feature, and I think it will be proved very useful in modern asyncio applications. @vmalloc, can you have a look?

BTW, right off the bat I see that the CI runs Python 2.7-3.6, and this feature needs 3.7 to be effective.

Also, since this PR started a long time ago, I can pick the devlopment from here if @miracle2k is too busy 😃

vmalloc commented 5 years ago

@matan129 Running Logbook on CI using 3.7 is not a trivial task (I tried to do it naively and failed) - the reason is that 3.7 requires a xenial environment, and that breaks the tons of setup the build has for stuff like ZeroMQ.

If you feel like it and have the time to open a PR to add 3.7, it would be greatly appreciated.

matan129 commented 5 years ago

Nitpicking a bit here, but I guess this PR can be closed now that #290 has been merged?

vmalloc commented 5 years ago

@miracle2k do you have any objections to closing this issue? Is there anything missing?