You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.
I am not sure why you would want to do this but I do believe gevent provides a workaround for situations like this.
For example you could do the following to achieve your timeout of 1 second:
msg=None# be aware that None is also returned when the websocket connection has closed# give the code within the with statement 1 second to run before it is forced to stopwithTimeout(1, False):
msg=ws.receive()
# check if we timed out without receiving a valueifmsgisNone:
msg="bob"# continue with your code
If you could explain why you want to do this I might be able to offer some better solutions for what you want to do.
our web client send msg not a regular time, but our web server must send data every 1 second. so, if I receive it, I can't send data every 1 second , if I do not receive it , I can't catch the msg.
so now , I used 2 threading to solve this,one receive msg one send data every 1 second. bug it is not pythonic.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I mean
msg = ws.receive(timeout=1, default='bob')
if client no send data, after 1 second , give a default value to msg
how to do like this? please!!!!!
The text was updated successfully, but these errors were encountered: