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

ResultRegistry has its stop method called before shutdown #62

Open
habnabit opened this issue May 29, 2014 · 1 comment
Open

ResultRegistry has its stop method called before shutdown #62

habnabit opened this issue May 29, 2014 · 1 comment

Comments

@habnabit
Copy link

That is,

        self._reactor.addSystemEventTrigger(
            "before", "shutdown", self._registry.stop)

I'm running into an issue now where I'm trying to process HTTP requests during reactor shutdown (a deferred was returned from a 'before shutdown' callback that fires when all HTTP requests are done), and some of the HTTP request processing uses crochet eventual results. Because the registry is stopped before shutdown, some of the HTTP requests die with a ReactorStopped error during processing.

@itamarst itamarst added this to the 1.3.0 milestone May 30, 2014
@itamarst
Copy link
Owner

I actually moved this from after shutdown to before shutdown as a fix for #17. The problem in general is that Twisted adds these events in the order addSystemEventTrigger is called, rather than the more useful reverse order (as e.g. TestCase.addCleanup does I believe). The problem in the specific is Twisted's ThreadPool doing thread joins waiting for them all to stop as part of shutdown, which is rather annoying.

Any ideas for solutions that address both use cases? A workaround is for your code to call addSystemEventTrigger first, but that's not great. Perhaps Twisted should move ThreadPool shutdown to the "after" phase, and then crochet registry shutdown can happen in the "during" phase... the whole shutdown process is hacky.

Lacking any good ideas I'm not going to put anything in the release I'm about to do.

@itamarst itamarst removed this from the 1.3.0 milestone May 31, 2014
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

2 participants