Open
Description
I find a problem when the client opens a stream and the server doesn't push anything, it will cause connection to stuck and won't close, then too many open files error happened.
So I edit some code to send some dummy messages (like ping) to prevent that happen.
And here's my workaround :
def generator():
pubsub = self.redis.pubsub()
pubsub.subscribe(channel)
try:
while True:
message = pubsub.get_message()
if message == None:
yield "event:ping\ndata:{}\n\n"
time.sleep(0.4)
elif message['type'] == 'message':
msg_dict = json.loads(message['data'])
yield str(Message(**msg_dict))
except GeneratorExit:
pass
except:
traceback.print_exc()
finally:
pubsub.unsubscribe(channel)
Metadata
Metadata
Assignees
Labels
No labels