Asynchronous work
Closed this issue ยท 7 comments
This issue is basically to start the discussion around asynchronous usage of this library, see if there are ideas/issues/restrictions around that.
I am particularly interested in working with this library from Twisted, but asyncio is now officially part of python.
There is https://github.com/crossbario/txaio which aims to be a bridge between both async frameworks.
Thoughts? Is it worth the time investment? or should I just build (and open-source) twisted-specific wrappers around authlib?
This is particularly interesting for the server side of things.
I myself think the implementation and the API of asyncio are terrible. It could be hard to support Python 2.7 in asyncio way. I'd like to add it later after Authlib turning to 1.0. Maybe async feature could be an Authlib 2.0 thing.
Asyncio is evolving and in 3.8 will be much better. You will not need to sting all code around loop
object. Only declare loop once. Also, 2.7 have the end of life date, which is very soon.
Seconding that you shouldn't really be worrying about 2.7
, the 2.*
line of python is going to be EOL in 2020, so nobody should be building new software on 2.*
.
You could write the code purely as an asynchronous library, then provide a synchronous API into it using loop.run_until_complete()
, but that seems like a bit of a pain...
I'm not sure what the advantage of using asyncio would be for this, as none of the web-frameworks it integrates with are natively asynchronous. Instead, why not document how to run authlib in a thread, from an asynchronous app? More on that here.
There is a plan to add async support in werkzeug which brings this issue to me. But I still think async should be added after v1.0. I should still focus on implementing the missing features.
Our client part is async now in v0.13.
We have async client now. Close this issue, we are not going to add async server until v2.0
If you look for a purely async oauth2 implementation, there is aioauth: https://github.com/aliev/aioauth, and I'm working on it to resolve this issue. It is MIT-licensed, fully test-covered, and simple, and I'd love to get your feedback or involvement.