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
Using emit in a background task is not working together with Popen. Please refer to the example below. I've tried to use the Popen from Eventlet too with no luck.
Environment: Windows 10
Python: 3.6.4
fromsubprocessimportPIPE, PopenfromflaskimportFlaskfromflask_socketioimportSocketIO, emitapp=Flask(__name__)
io=SocketIO(app, async_mode='eventlet')
defemit_docker_logs():
whileTrue:
command= ['docker', 'logs', '-f', 'web-server']
proc=Popen(command, stdout=PIPE, stderr=PIPE, universal_newlines=True)
whileproc.poll() isNone:
line=str(proc.stdout.readline(), 'utf-8')
ifline:
print(line) # This gets printed.io.emit('logdata', line) # The client does not receive this line.print(proc.stderr.readline())
io.sleep(10)
if__name__=='__main__':
io.start_background_task(target=emit_docker_logs)
io.run(app)
The text was updated successfully, but these errors were encountered:
Using
emit
in a background task is not working together withPopen
. Please refer to the example below. I've tried to use thePopen
from Eventlet too with no luck.Environment: Windows 10
Python: 3.6.4
The text was updated successfully, but these errors were encountered: