Skip to content

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

Merged
bdarnell merged 6 commits intotornadoweb:masterfrom
bestcondition:tornado_selector_context
May 14, 2025
Merged

Fixed the bug that the handler cannot get the main thread context on the Windows platform.#3479
bdarnell merged 6 commits intotornadoweb:masterfrom
bestcondition:tornado_selector_context

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