Skip to content
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

getting assert error #2753

Closed
himanshu4code opened this issue Oct 11, 2019 · 7 comments
Closed

getting assert error #2753

himanshu4code opened this issue Oct 11, 2019 · 7 comments

Comments

@himanshu4code
Copy link

himanshu4code commented Oct 11, 2019

ERROR:tornado.application:Error in connection callback
Traceback (most recent call last):
File "/home/ongraph/Desktop/botuserv/lib/python3.7/site-packages/tornado/tcpserver.py", line 327, in _handle_connection
future = self.handle_stream(stream, address)
File "/home/ongraph/Desktop/botuserv/lib/python3.7/site-packages/tornado/httpserver.py", line 229, in handle_stream
conn.start_serving(self)
File "/home/ongraph/Desktop/botuserv/lib/python3.7/site-packages/tornado/http1connection.py", line 810, in start_serving
self.stream.io_loop.add_future(fut, lambda f: f.result())
File "/home/ongraph/Desktop/botuserv/lib/python3.7/site-packages/tornado/ioloop.py", line 693, in add_future
assert is_future(future)
AssertionError

when i checked i found out that future get object of Http1ServerConnection.
<Task pending coro=<HTTP1ServerConnection._server_request_loop() >>

@bdarnell
Copy link
Member

That's a Task object, and asyncio.Task is a subclass of asyncio.Future, so this should have worked. I'm not sure what could cause something like this. Are you perhaps using a third-party event loop implementation like uvloop?

@dogukankotan
Copy link

+1 for me
I'm using Flask and Tornado. The code blocks working, however it gives AssertionError at the background.

Flask==1.0.3
tornado==6.0.3

import asyncio
import nest_asyncio
nest_asyncio.apply(loop=asyncio.get_event_loop())

@ploxiln
Copy link
Contributor

ploxiln commented Jan 15, 2020

so it seems there's this thing that people try to use: https://github.com/erdewit/nest_asyncio

@bdarnell
Copy link
Member

@dogukankotan What's the exact error? Is it the same one as @himanshu4code or something different?

I don't really trust nest_asyncio. Tornado has not been written with reentrant event loops in mind. If you think you need a reentrant event loop, I recommend the two-thread solution from #2798 (comment) instead.

@dogukankotan
Copy link

I fixed the issue downgrade to 4.5.3.
@bdarnell yes same error. In my flask project there are some healthcheck methods work in async. So, I think new version of Tornado uses its event loop.

@bdarnell
Copy link
Member

Closing since it sounds like this was caused by nest_asyncio. Feel free to reopen with more details if that's not the case.

@maartenbreddels
Copy link
Contributor

FYI: In vaex I solve it by patching Tornado:
https://github.com/vaexio/vaex/blob/10e1d5077021a0590d3750d62d4d56a27a84af82/packages/vaex-core/vaex/asyncio.py

I opened an issue at erdewit/nest_asyncio#23 but it's neither's fault I think, it's just on the edge of what is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants