Skip to content

Fixed the bug that the handler cannot get the main thread context on the Windows platform. #3479

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

Merged
merged 6 commits into from
May 14, 2025

Conversation

bestcondition
Copy link
Contributor

platform

windows

minimal reproducible demo

import tornado.ioloop
import tornado.web

import contextvars

v = contextvars.ContextVar('v', default='default')


# Define a request handler
class MainHandler(tornado.web.RequestHandler):
    def get(self):
        print(v.get())
        self.write("Hello, World!")


# Define the application
def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])


# Start the server
if __name__ == "__main__":
    v.set('foo')
    app = make_app()
    app.listen(8888)  # Listen on port 8888
    print("Server is running on http://localhost:8888")
    tornado.ioloop.IOLoop.current().start()

Run and visit http://localhost:8888, then print default

@bestcondition
Copy link
Contributor Author

@bdarnell , hello! My pull request has been open for a while, and I would appreciate it if you could take a look. Thank you very much for your contributions to this project! I look forward to your feedback.

@bdarnell
Copy link
Member

Thanks and sorry for the delay. The change looks good, but would you mind adding a simple test case for it?

@bestcondition
Copy link
Contributor Author

Thanks and sorry for the delay. The change looks good, but would you mind adding a simple test case for it?

@bdarnell I tried to add a test case, please review.

@bdarnell
Copy link
Member

Merge or rebase onto current master to fix the tox issues. This is ready to merge as soon as we get a clean CI run.

@bdarnell bdarnell merged commit ae4a4e4 into tornadoweb:master May 14, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants