From 282ae99cab1f1b7ae36a3478c2debdd1969f4453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Wed, 21 May 2014 21:18:01 +0200 Subject: [PATCH] [fix] Display messages in real-time in the api --- moulinette/interfaces/api.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/moulinette/interfaces/api.py b/moulinette/interfaces/api.py index 91e5c893..916d66f5 100644 --- a/moulinette/interfaces/api.py +++ b/moulinette/interfaces/api.py @@ -8,10 +8,12 @@ import binascii import argparse from json import dumps as json_encode -from bottle import run, request, response, Bottle, HTTPResponse +from gevent import sleep from gevent.queue import Queue from geventwebsocket import WebSocketError +from bottle import run, request, response, Bottle, HTTPResponse + from moulinette.core import MoulinetteError, clean_session from moulinette.interfaces import (BaseActionsMapParser, BaseInterface) @@ -340,6 +342,10 @@ class _ActionsMapPlugin(object): # Put the message as a 2-tuple in the queue queue.put_nowait((style, message)) + # Put the current greenlet to sleep for 0 second in order to + # populate the new message in the queue + sleep(0) + # HTTP Responses -------------------------------------------------------