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

Broken Scheduler.close() behavior on BaseException #39

Open
himikof opened this issue May 10, 2018 · 3 comments
Open

Broken Scheduler.close() behavior on BaseException #39

himikof opened this issue May 10, 2018 · 3 comments

Comments

@himikof
Copy link

himikof commented May 10, 2018

If a BaseException which is not an Exception is thrown inside a job (for example, KeyboardInterrupt), the Scheduler._wait_failed() task fails to catch this exception after re-raising it, and this exception gets raised from the Scheduler.close() method (due to await self._failed_task), which is totally unexpected.

Probably the intended invariant in Scheduler._wait_failed() was to never raise an exception.

@asvetlov
Copy link
Member

It is the hard question.
By catching KeyboardInterrupt user has no chance to stop the program.
I don't sure if the behavior should be changed.

@himikof
Copy link
Author

himikof commented May 14, 2018

No, the application has already received the KeyboardInterrupt (by awaiting the job future), and is in the process of graceful shutdown (in the exception handler). In the process of the shutdown it calls Scheduler.close(), which unexpectedly raises another KeyboardInterrupt, which then aborts the graceful termination.

@asvetlov
Copy link
Member

I have a feeling that the problem should be fixed by asyncio itself somehow, not by aiojobs.
Otherwise, every asyncio library should catch and process KeyboardInterrupt on every await expression.

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