question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

async/await for twisted ApplicationSession

See original GitHub issue

From 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:closed
  • Created 7 years ago
  • Comments:14 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
oberstetcommented, Aug 22, 2017

Ah, right;) Ok, then as far as I see, there is actually 2 issues here:

  1. txaio: add the ensureDeferred support to txaio.as_future
  2. AB: actually use it (also in WebSocket code) 😉 as above grep shows, it is only used in 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?

0reactions
oberstetcommented, Mar 23, 2018

async/await should be fully usable on Py3/Twisted now with Autobahn

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found