Skip to content

Commit

Permalink
sse: gotta use a special version of zeromq (zmq.green) when in gevent…
Browse files Browse the repository at this point in the history
… context
  • Loading branch information
alexAubin committed Nov 6, 2024
1 parent c89f59d commit f625b30
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions moulinette/interfaces/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def logout(self):

def sse(self):
import time
import zmq
import zmq.green as zmq

# FIXME : check auth...

Expand All @@ -395,13 +395,14 @@ def sse(self):
# Set client-side auto-reconnect timeout, ms.
yield 'retry: 100\n\n'

while True:
try:
try:
while True:
if sub.poll(10, zmq.POLLIN):
_, msg = sub.recv_multipart()
yield 'data: ' + str(msg.decode()) + '\n\n'
except KeyboardInterrupt:
break
finally:
sub.close()
ctx.term()

def process(self, _route, arguments={}):
"""Process the relevant action for the route
Expand Down

0 comments on commit f625b30

Please sign in to comment.