Skip to content

Exiting the socket is being delayed #1584

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

Open
tsunamilx opened this issue May 12, 2025 · 2 comments
Open

Exiting the socket is being delayed #1584

tsunamilx opened this issue May 12, 2025 · 2 comments
Assignees

Comments

@tsunamilx
Copy link

I dont think the issue existed before, but I recently found that the socket (either ReconnectingSocket or KeepAliveSocket), the __aexit__ is always delayed for exact 10 seconds:

async with socket:
    print('done')
print('close')  # this message is always 10 secs late after the 'done' message  

I dig a little bit of the code and I think it is because the socket is waiting for data in the _read_loop:

res = await asyncio.wait_for(
    self.ws.recv(), timeout=self.TIMEOUT
)

and self.TIMEOUT is 10, which explains the 10 secs delay.

Am I right? And how do you remove the delay?

@tsunamilx tsunamilx changed the title Question about exiting the socket Exiting the socket is being delayed May 12, 2025
@pcriadoperez pcriadoperez self-assigned this May 13, 2025
@pcriadoperez
Copy link
Collaborator

Hi @tsunamilx ,

Correct, on exit we kill the read loop, which if it's streaming it would wait till the next message or the timeout to go over the loop and exit.
Would editing the value of self.TIMEOUT to a smaller value work for you?

@tsunamilx
Copy link
Author

tsunamilx commented May 13, 2025

Hi @pcriadoperez , yes, editing self.TIMEOUT to a smaller value would work, I guess this is only way for now.

This issue didn't exist before if I remember correctly, what's changed and what was the problem before the change?

Thanks.

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

No branches or pull requests

2 participants