Skip to content

Commit 87d51dd

Browse files
databasedavavi
andauthored
ASGI startup and shutdown lifespan handlers (miguelgrinberg#468)
Co-authored-by: avi <senavi@berkeley.edu>
1 parent 76a9860 commit 87d51dd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

socketio/asgi.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class ASGIApp(engineio.ASGIApp): # pragma: no cover
1616
:param socketio_path: The endpoint where the Socket.IO application should
1717
be installed. The default value is appropriate for
1818
most cases.
19+
:param on_startup: function to be called on application startup; can be
20+
coroutine
21+
:param on_shutdown: function to be called on application shutdown; can be
22+
coroutine
1923
2024
Example usage::
2125
@@ -30,7 +34,9 @@ class ASGIApp(engineio.ASGIApp): # pragma: no cover
3034
uvicorn.run(app, host='127.0.0.1', port=5000)
3135
"""
3236
def __init__(self, socketio_server, other_asgi_app=None,
33-
static_files=None, socketio_path='socket.io'):
37+
static_files=None, socketio_path='socket.io',
38+
on_startup=None, on_shutdown=None):
3439
super().__init__(socketio_server, other_asgi_app,
3540
static_files=static_files,
36-
engineio_path=socketio_path)
41+
engineio_path=socketio_path, on_startup=on_startup,
42+
on_shutdown=on_shutdown)

0 commit comments

Comments
 (0)