hypercorn
hypercorn copied to clipboard
ImportError: cannot import name 'LifespanFailure' from 'hypercorn.utils'
Hello.
After automatically upgrading to the newest version (0.12.0):
ImportError: cannot import name 'LifespanFailure' from 'hypercorn.utils'
I can see that in 0.12.0 LifespanFailure was renamed to LifespanFailureError (along with other renamings).
Is 0.12.0 considered to have breaking changes?
Thank you! Adam
I didn't think LifespanFailure would be used outside of the Hypercorn code directly - I'd like to learn about your usage.
It is a renaming, I'll add it to the changelog.
So basically what I have is this:
from hypercorn.utils import LifespanFailure
try:
await self.app(<some params>)
except LifespanFailure:
pass
It is being used like this in one of the middlewares.
I'm not sure that these errors should leak out to the middleware - I guess this is an app that doesn't support lifespans?
Yes, that makes sense. So it looks like it could be the fault on the application side then. Thank you!
Thinking about this some more, I think the specification allows for any Exception subclass to be raised - so I don't think your middleware should rely on it being a LifespanFailureError.