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

Enhancement: after_startup and after_shutdown hook #3730

Closed
m3nowak opened this issue Sep 13, 2024 · 2 comments
Closed

Enhancement: after_startup and after_shutdown hook #3730

m3nowak opened this issue Sep 13, 2024 · 2 comments
Labels
Enhancement This is a new feature or request

Comments

@m3nowak
Copy link

m3nowak commented Sep 13, 2024

Summary

Issue #2375 mentions, that after_startup and after_shutdown hooks have been removed. However, it is a feature, which I need.
Right now, I'm developing a service for receiving web hooks. After application start, I need to inform remote service, that my server started accepting requests.

Basic Example

app = Litestar(
    [index],
    after_startup=[lambda: print("Application started up!")]
)

Drawbacks and Impact

No response

Unresolved questions

My current workaround is running desired function after asyncio.sleep together with ASGI server in asyncio.gather. Is there a better alternative?


Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@m3nowak m3nowak added the Enhancement This is a new feature or request label Sep 13, 2024
@Alc-Alc
Copy link
Contributor

Alc-Alc commented Sep 14, 2024

Will lifespan work for your use case?

@provinzkraut
Copy link
Member

See discussions in #3598 and #3597.

Closing as duplicate.

@Alc-Alc is correct, using lifespan is the way to go here.

@provinzkraut provinzkraut closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement This is a new feature or request
Projects
None yet
Development

No branches or pull requests

3 participants