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

AsyncServer.enter_room() is not awaitable #1256

Closed
tt2468 opened this issue Oct 13, 2023 · 3 comments
Closed

AsyncServer.enter_room() is not awaitable #1256

tt2468 opened this issue Oct 13, 2023 · 3 comments
Labels

Comments

@tt2468
Copy link
Contributor

tt2468 commented Oct 13, 2023

Describe the bug
When attempting to call AsyncServer.enter_room() with await, a TypeError exception is thrown:

TypeError: object NoneType can't be used in 'await' expression

To Reproduce
Steps to reproduce the behavior:

  1. Implement a basic AsyncServer class
  2. On connect, attempt to enter SID into a room with await sio.enter_room(sid, 'testroom')
  3. TypeError will be thrown

Calling the function without an await statement enters the client into the room as expected.

Expected behavior
The docs, along with code, label this function as a coroutine, when in fact it does not return any awaitable, making it functionally not a coroutine.

Additional context
The enter_room() method calls the AsyncServer's manager instance:

async def enter_room(self, sid, namespace, room, eio_sid=None):

Which calls the synchronous inherited function, basic_enter_room(). As such, None is returned instead of an awaitable.

@miguelgrinberg
Copy link
Owner

The enter_room and leave_room methods were not awaitable, and they should have been. I noticed this recently and have fixed it. These fixes have not been released yet.

My guess is that you are reading the "latest" version of the docs, which maps to the main branch. The "stable" docs should show these methods as regular functions. This is obviously going to be a breaking change.

@tt2468
Copy link
Contributor Author

tt2468 commented Oct 13, 2023

Ah, cool. By chance do you mind pinging or closing this issue when a release is made with these changes?

@miguelgrinberg
Copy link
Owner

The release with the async enter/leave room is out now. This is in version 5.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants