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

Explicitly maintain a reference to a _HandlerDelegate's task. #3319

Closed

Conversation

thetorpedodog
Copy link

This ensures that, when an async task for an HTTP handler delegate is running, a strong reference is maintained at all times by the delegate itself.

This is a complement to #3269. While that change creates a global store of running tasks, this one independently stores it locally.


This is essentially a suggestion of one other possible way that we could Do The Right Thing in the web module rather than just relying on the global store. Empirically, it appears to be working correctly (i.e., all tasks maintain a reference and run to completion) when running this, given that this branch does not contain #3269.

My feeling is that even with that other change, we should still do this (or something like it) to avoid the semi-undocumented dependency on the global strong task store. This particular implementation is something I threw together, and I invite suggestions, or you could even simply take the concept and reimplement it however you prefer.

This ensures that, when an async task for an HTTP handler delegate
is running, a strong reference is maintained at all times by
the delegate itself.

This is a complement to tornadoweb#3269.
While that change creates a global store of running tasks, this one
independently stores it locally.
@bdarnell
Copy link
Member

I'm not sure about this - it creates a hard link from the _HandlerDelegate to the Future, but what holds a reference to the _HandlerDelegate (the same should apply to the RequestHandler)? I think there's still a gap without #3269, and with #3269, what does this one add?

@thetorpedodog
Copy link
Author

This was just a stab at something that might work and improved things in my observation. I’m not entirely familiar with Tornado’s internals so I had assumed that the delegate would be somehow attached to a GC root. Like I said, feel free to adapt or even drop this if it doesn’t make sense.

@bdarnell
Copy link
Member

bdarnell commented Sep 2, 2023

Since the goal is to eliminate the need for these hard references (and I'm wary of the effects of circular references on GC), I'm going to close this.

@bdarnell bdarnell closed this Sep 2, 2023
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.

None yet

2 participants