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

Ensure cleanup gets run. #4800

Closed
wants to merge 3 commits into from
Closed

Ensure cleanup gets run. #4800

wants to merge 3 commits into from

Conversation

Dreamsorcerer
Copy link
Member

@Dreamsorcerer Dreamsorcerer commented Jun 6, 2020

This helps ensure that cleanup gets run, even when an exception occurs during startup. Fixes #4799

This becomes particularly painful when the server can't be cleanly restarted without the cleanup running, especially when running locally with aiohttp-devtools, where exceptions during development are likely, and cause the runserver command to break or lock up.

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2020

Codecov Report

Merging #4800 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4800      +/-   ##
==========================================
- Coverage   97.60%   97.60%   -0.01%     
==========================================
  Files          43       43              
  Lines        8932     8931       -1     
  Branches     1406     1406              
==========================================
- Hits         8718     8717       -1     
  Misses         95       95              
  Partials      119      119              
Impacted Files Coverage Δ
aiohttp/web_runner.py 97.76% <ø> (-0.02%) ⬇️
aiohttp/web_app.py 97.32% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 385b03e...84b6c9e. Read the comment docs.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry but 'no'.
startup/cleanup works like try/finally block:

await startup()
try:
    await serve_http()
finally:
    await cleanup()

if startup call raises exception -- cleanup is not called.

@asvetlov asvetlov closed this Oct 16, 2020
@Dreamsorcerer
Copy link
Member Author

@asvetlov I was thinking about tweaking this PR to only run parts with a cleanup context.

The problem I am encountering is that development is hard using the devtools, as whenever an exception occurs during startup, the application is left hanging and doesn't restart as it normally would.

It seems odd to me that a cleanup context would be left in an in-between state. The result is that e.g. a DB or other process doesn't get shut down due to an unrelated part of the application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cleanup doesn't run when exception occurs in startup.
3 participants