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

Update for tornado 6 #6

Conversation

joergenreyes0
Copy link
Contributor

@joergenreyes0 joergenreyes0 commented Oct 31, 2023

Tornado 6 removed the io_loop parameter, which removed the ability to create and pass in your own instance of it. This PR makes baiocas compatible with tornado 6 by removing the ability to create or pass in IOLoops to tornado. For code that runs functions on IOLoops created the old way, IOLoop.current() is used to get the current instance instead.

Tornado 6 also removed the Task function (deprecated in v5), which adapted callback-based functions to be used in coroutines. Task was used to call AsyncHTTPClient.fetch and get a Future instance. However,fetch in v6 removed the callback argument and returns a Future instance directly (documentation), so this PR changes baiocas to just call the function directly and use its return value.

Test cases pass.

Since the use of io_loop as a function parameter in tornado is removed, IOLoop.current() is the way to get the instance and run functions on it
Task was also deprecated and removed in tornado 6, but it's also not useful anymore since the function "fetch" that was being called also no longer supports the "callback" argument that Task was supplying. It instead recommends to use the returned Future instance instead, which is the same as what Task used to do.
Comment on lines +47 to +48
# Use the default IO loop
self.io_loop = IOLoop.current()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere since it's not going into LongPollingTransport?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.io_loop is used later in the Client class on lines 161 and 210.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if that can be refactored too, but no need to figure that out now.

baiocas/transports/long_polling.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ViViDboarder ViViDboarder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm pretty sure the failures are on master due to old python versions and old config. I'll get this merged, fix that up, and then tag a release.

@ViViDboarder ViViDboarder merged commit 66c2831 into silentsound:master Nov 17, 2023
2 of 7 checks passed
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

Successfully merging this pull request may close these issues.

2 participants