-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio support #373
Comments
Hm, it looks like this does not work with current master. But works fine with pypi version. |
Ok, more canonical example from documentation works fine on python 3.4.6 with current master. import asyncio
from flexx import app, ui
from tornado.platform.asyncio import AsyncIOMainLoop
class Example(ui.Widget):
def init(self):
with ui.HBox():
ui.Button(flex=1, text="hello")
ui.Button(flex=1, text="world")
asyncio.ensure_future(self.yoba())
@asyncio.coroutine
def yoba(self):
while True:
loop = asyncio.get_event_loop()
print(id(loop), loop)
yield from asyncio.sleep(1)
AsyncIOMainLoop().install()
app.serve(Example)
app.start() Update: |
Multiple connections are simply handled as events. There is exactly one event loop (in a single thread). Leaving this open as a todo to document the usage. Also related to #142 |
It looks like there is cheap way to use asyncio with flexx. But I'm not sure how it will work with many connections from browser, since I'm not familiar with flexx internals. More than one event loop? Threads?
I'm asking core devs to inspect this code and check corner cases. It will be very nice, if flexx will support asyncio officially and documentation takes paragraph about it.
The text was updated successfully, but these errors were encountered: