Browse Source

Add missing `async` on session examples for the async server (#1465)

main
Func 2 days ago
committed by GitHub
parent
commit
5e04003dad
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      src/socketio/async_server.py

6
src/socketio/async_server.py

@ -373,15 +373,15 @@ class AsyncServer(base_server.BaseServer):
context manager block are saved back to the session. Example usage:: context manager block are saved back to the session. Example usage::
@eio.on('connect') @eio.on('connect')
def on_connect(sid, environ): async def on_connect(sid, environ):
username = authenticate_user(environ) username = authenticate_user(environ)
if not username: if not username:
return False return False
with eio.session(sid) as session: async with eio.session(sid) as session:
session['username'] = username session['username'] = username
@eio.on('message') @eio.on('message')
def on_message(sid, msg): async def on_message(sid, msg):
async with eio.session(sid) as session: async with eio.session(sid) as session:
print('received message from ', session['username']) print('received message from ', session['username'])
""" """

Loading…
Cancel
Save