Skip to content

Commit

Permalink
🪲 Lifespan async generator for shell
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsil committed Apr 21, 2023
1 parent 014a07b commit 9dca562
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## 0.7.1

### Fixed

- `Lifespan` event on shell returning async manager.

## 0.7.0

### Changed
Expand Down
2 changes: 1 addition & 1 deletion saffier/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.7.0"
__version__ = "0.7.1"

from saffier.conf import settings
from saffier.conf.global_settings import SaffierSettings
Expand Down
10 changes: 4 additions & 6 deletions saffier/migrations/operations/shell/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def shell(env: MigrationEnv, kernel: bool) -> None:
exec(sys.stdin.read(), globals())
return

on_startup = getattr(env.app, "on_startup", None)
on_shutdown = getattr(env.app, "on_shutdown", None)
on_startup = getattr(env.app, "on_startup", [])
on_shutdown = getattr(env.app, "on_shutdown", [])
lifespan = getattr(env.app, "lifespan", None)
lifespan = handle_lifespan_events(
on_startup=on_startup, on_shutdown=on_shutdown, lifespan=lifespan
Expand Down Expand Up @@ -73,8 +73,6 @@ def handle_lifespan_events(
declaration for legacy and comprehension purposes and build the async context manager
for the lifespan.
"""
if on_startup or on_shutdown:
return AyncLifespanContextManager(on_startup=on_startup, on_shutdown=on_shutdown)
elif lifespan:
if lifespan:
return lifespan
return None
return AyncLifespanContextManager(on_startup=on_startup, on_shutdown=on_shutdown)

0 comments on commit 9dca562

Please sign in to comment.