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

AttributeError: '_NullFuture' object has no attribute 'add_done_callback' #3287

Open
dryalcinmehmet opened this issue Jun 20, 2023 · 5 comments

Comments

@dryalcinmehmet
Copy link

Hi,

I deployed tornado web with these versions.

Ubuntu 18.04 Python 3.11.4 Tornado 6.3.2

I couldn't solve the issue as you see below.

Currently, we use Tornado 5.0.2 and Python 3.6.9 versions. We decided upgrade python to 3.11.4 and all packages. I tried versions of tornado from 5.0 to 6.3.2, but couldn't solve.

E 230620 15:07:01 http1connection:67] Uncaught exception Traceback (most recent call last): File "/home/shippn/.pyenv/versions/venv/lib/python3.11/site-packages/tornado/http1connection.py", line 276, in _read_message delegate.finish() File "/home/shippn/.pyenv/versions/venv/lib/python3.11/site-packages/tornado/routing.py", line 268, in finish self.delegate.finish() File "/home/shippn/.pyenv/versions/venv/lib/python3.11/site-packages/tornado/web.py", line 2395, in finish self.execute() File "/home/shippn/.pyenv/versions/venv/lib/python3.11/site-packages/tornado/web.py", line 2434, in execute fut.add_done_callback(lambda f: f.result()) ^^^^^^^^^^^^^^^^^^^^^ AttributeError: '_NullFuture' object has no attribute 'add_done_callback'

@bdarnell
Copy link
Member

Hmm, I've never seen that and I'm not quite sure how you'd get there. Are you overriding RequestHandler._execute somehow?

@bhch
Copy link

bhch commented Jun 21, 2023

What you've written is unnecessarily complicated and, not to mention, results in error.

Instead of patching RequestHandler._execute method, you should instead perform the authentication checks in the RequestHandler.prepare method of the base class.

@dryalcinmehmet
Copy link
Author

dryalcinmehmet commented Jun 21, 2023

Hi,
Thank you for comment, the codes are not solid I know that, I am new in the project, I wanna figure out the issue, can you refactor any part for me?

@piraz
Copy link
Contributor

piraz commented Jun 21, 2023

On the file provided by @dryalcinmehmet, there is an options method decorated with tornado.gen.coroutine, no yields just returns. Should that the be source of the _NullFuture?

@bdarnell
Copy link
Member

there is an options method decorated with tornado.gen.coroutine, no yields just returns. Should that the be source of the _NullFuture?

No, tornado.gen.coroutine should still use a real future in this case.

I don't see exactly where the _NullFuture is coming from, but this interceptor decorator is problematic in a number of ways. Wrapping _execute without actually calling the underlying _execute method is probably going to break something, as is discarding the return value of the real _execute method.

I agree with @bhch that you should not be overriding _execute here and should do your auth checks in prepare() instead. We previously kinda-supported overriding _execute because prepare couldn't be asynchronous, but now that we support coroutines in prepare there's no reason to override _execute any more and you should stay away from it.

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

4 participants