async/await for twisted ApplicationSession
See original GitHub issueFrom the version 16.4 twisted support async/await (py3.5+) https://twistedmatrix.com/documents/current/core/howto/defer-intro.html#coroutines-with-async-await
but it doesn’t work in crossbar (crossbar-0.15, autobahn-0.16.0, py3.5, twisted-16.4.1, txaio-2.5.1):
from autobahn.twisted.wamp import ApplicationSession
from autobahn.wamp.exception import ApplicationError
class AuthenticatorSession(ApplicationSession):
async def onJoin(self, details):
async def authenticate(realm, authid, details):
ticket = details['ticket']
....
return data['role']
try:
await self.register(authenticate, 'com.app.authenticate')
self.log.info("Dynamic authenticator registered")
except Exception as e:
raise e
in logs i have warning: ...python3.5/site-packages/twisted/internet/defer.py:587: builtins.RuntimeWarning: coroutine 'onJoin' was never awaited
so, will be fine support this or if this is my fail - add example (re #653)
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (12 by maintainers)
Top Results From Across the Web
WAMP Programming — autobahn 22.8.1.dev1 documentation
You can use the same “component” APIs to run a component based on subclassing ApplicationSession . In older code it's common to see...
Read more >docs · for/vtk · third-party / autobahn-python - Kitware GitLab
in Python 2 and 3, running on `Twisted`_ or `asyncio`_. ... from autobahn.twisted.wamp import ApplicationSession # or: from autobahn.asyncio.wamp import ...
Read more >Using Asyncio in Twisted. 09 Jul 2018 | by Yash Sharma
This Blogpost deals with supporting Asyncio in Twisted. ... Normally, Twisted had support for native coroutines( async/await ), and we can ...
Read more >How to use the autobahn.twisted.wamp.ApplicationSession ...
To help you get started, we've selected a few autobahn.twisted.wamp.ApplicationSession examples, based on popular ways it is used in public projects.
Read more >Issues · crossbario/autobahn-python · GitHub
Document overriding with ApplicationSession docs ... Expand programming guides with async/await style code/idioms docs. #653 opened Apr 28, 2016 by oberstet.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, right;) Ok, then as far as I see, there is actually 2 issues here:
ensureDeferred
support totxaio.as_future
onConnect
right now, but it should be used in the other hooks as well …Both can be done without breaking interfaces.
Does that make sense?
async/await should be fully usable on Py3/Twisted now with Autobahn