Flask socketIo with gevent not working when debug=False2019 Community Moderator ElectionSocketio client switching to xhr-polling running with flask appFlask-socketio, emit an event to another namespaceFlask debug mode when using socketsflask and flask-socketio flush all emit eventsUse socket.io to display realtime dataFlask-SocketIO + uWSGI. Emit with Mule workerflask socketio - server does not reload or updateUnable to pass button event to Flask SocketIO to external python programPython flask socketio at ubuntu 16.04(transport=pooling error)Python 3.7 Flask-SocketIO + uWSGI + nginx configuration

Factor Rings over Finite Fields

Writing text next to a table

What will happen if my luggage gets delayed?

Are small insurances worth it?

Smooth vector fields on a surface modulo diffeomorphisms

Does the US political system, in principle, allow for a no-party system?

Is "cogitate" used appropriately in "I cogitate that success relies on hard work"?

How to educate team mate to take screenshots for bugs with out unwanted stuff

How exactly does an Ethernet collision happen in the cable, since nodes use different circuits for Tx and Rx?

Use Mercury as quenching liquid for swords?

Either of .... (Plural/Singular)

Do Paladin Auras of Differing Oaths Stack?

Converting from "matrix" data into "coordinate" data

Is it a Cyclops number? "Nobody" knows!

When an outsider describes family relationships, which point of view are they using?

What can I do if someone tampers with my SSH public key?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

How to install round brake pads

Why is there an extra space when I type "ls" on the Desktop?

Which country has more?

Can one live in the U.S. and not use a credit card?

Does an unused member variable take up memory?

Logistic regression BIC: what's the right N?

Can I negotiate a patent idea for a raise, under French law?



Flask socketIo with gevent not working when debug=False



2019 Community Moderator ElectionSocketio client switching to xhr-polling running with flask appFlask-socketio, emit an event to another namespaceFlask debug mode when using socketsflask and flask-socketio flush all emit eventsUse socket.io to display realtime dataFlask-SocketIO + uWSGI. Emit with Mule workerflask socketio - server does not reload or updateUnable to pass button event to Flask SocketIO to external python programPython flask socketio at ubuntu 16.04(transport=pooling error)Python 3.7 Flask-SocketIO + uWSGI + nginx configuration










0















I am running a Flask application on a Raspberry Pi running on a uWSGI server. I am trying to implement a WebSocket protocol with Flask-socketIo combined with gevent & gevent-websocket as specified in the doc.



When I start the app with this line I got no issue, the data is sent to the client thru websocket as expected:



socketio.run(app, host='0.0.0.0', port=80, debug=True)


However if debug is set to False, the emit function is no longer working.



def updateSensorsState(sensor):
print "update"
socketio.emit('state', json.dumps(sensor))


In this case when I press a button updateSensorState(sensor) is called from a GPIO callback. I get update printed in the console and the emit function seems to hang there. If I press the button many time, once in a while the client will receive a queue of message many time later...



Any advice to help me what is going on with my code would be much apreciated.
Thank you.










share|improve this question






















  • Are you also using GPIO when you run in debug mode? I doubt gevent is compatible with that, whatever you do with hardware is likely blocking.

    – Miguel
    Mar 6 at 21:27











  • Yes I run the exact same code with the GPIO. It works in debug and hang when debug is set to False... I also tried with evenlet and same thing happend.

    – Nicolas Foisy
    Mar 6 at 22:01












  • @Miguel If I run socketio = SocketIO(app, async_mode='threading') and debug=False it also works with long polling.

    – Nicolas Foisy
    Mar 6 at 22:09















0















I am running a Flask application on a Raspberry Pi running on a uWSGI server. I am trying to implement a WebSocket protocol with Flask-socketIo combined with gevent & gevent-websocket as specified in the doc.



When I start the app with this line I got no issue, the data is sent to the client thru websocket as expected:



socketio.run(app, host='0.0.0.0', port=80, debug=True)


However if debug is set to False, the emit function is no longer working.



def updateSensorsState(sensor):
print "update"
socketio.emit('state', json.dumps(sensor))


In this case when I press a button updateSensorState(sensor) is called from a GPIO callback. I get update printed in the console and the emit function seems to hang there. If I press the button many time, once in a while the client will receive a queue of message many time later...



Any advice to help me what is going on with my code would be much apreciated.
Thank you.










share|improve this question






















  • Are you also using GPIO when you run in debug mode? I doubt gevent is compatible with that, whatever you do with hardware is likely blocking.

    – Miguel
    Mar 6 at 21:27











  • Yes I run the exact same code with the GPIO. It works in debug and hang when debug is set to False... I also tried with evenlet and same thing happend.

    – Nicolas Foisy
    Mar 6 at 22:01












  • @Miguel If I run socketio = SocketIO(app, async_mode='threading') and debug=False it also works with long polling.

    – Nicolas Foisy
    Mar 6 at 22:09













0












0








0








I am running a Flask application on a Raspberry Pi running on a uWSGI server. I am trying to implement a WebSocket protocol with Flask-socketIo combined with gevent & gevent-websocket as specified in the doc.



When I start the app with this line I got no issue, the data is sent to the client thru websocket as expected:



socketio.run(app, host='0.0.0.0', port=80, debug=True)


However if debug is set to False, the emit function is no longer working.



def updateSensorsState(sensor):
print "update"
socketio.emit('state', json.dumps(sensor))


In this case when I press a button updateSensorState(sensor) is called from a GPIO callback. I get update printed in the console and the emit function seems to hang there. If I press the button many time, once in a while the client will receive a queue of message many time later...



Any advice to help me what is going on with my code would be much apreciated.
Thank you.










share|improve this question














I am running a Flask application on a Raspberry Pi running on a uWSGI server. I am trying to implement a WebSocket protocol with Flask-socketIo combined with gevent & gevent-websocket as specified in the doc.



When I start the app with this line I got no issue, the data is sent to the client thru websocket as expected:



socketio.run(app, host='0.0.0.0', port=80, debug=True)


However if debug is set to False, the emit function is no longer working.



def updateSensorsState(sensor):
print "update"
socketio.emit('state', json.dumps(sensor))


In this case when I press a button updateSensorState(sensor) is called from a GPIO callback. I get update printed in the console and the emit function seems to hang there. If I press the button many time, once in a while the client will receive a queue of message many time later...



Any advice to help me what is going on with my code would be much apreciated.
Thank you.







flask raspberry-pi gevent flask-socketio






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 13:38









Nicolas FoisyNicolas Foisy

135




135












  • Are you also using GPIO when you run in debug mode? I doubt gevent is compatible with that, whatever you do with hardware is likely blocking.

    – Miguel
    Mar 6 at 21:27











  • Yes I run the exact same code with the GPIO. It works in debug and hang when debug is set to False... I also tried with evenlet and same thing happend.

    – Nicolas Foisy
    Mar 6 at 22:01












  • @Miguel If I run socketio = SocketIO(app, async_mode='threading') and debug=False it also works with long polling.

    – Nicolas Foisy
    Mar 6 at 22:09

















  • Are you also using GPIO when you run in debug mode? I doubt gevent is compatible with that, whatever you do with hardware is likely blocking.

    – Miguel
    Mar 6 at 21:27











  • Yes I run the exact same code with the GPIO. It works in debug and hang when debug is set to False... I also tried with evenlet and same thing happend.

    – Nicolas Foisy
    Mar 6 at 22:01












  • @Miguel If I run socketio = SocketIO(app, async_mode='threading') and debug=False it also works with long polling.

    – Nicolas Foisy
    Mar 6 at 22:09
















Are you also using GPIO when you run in debug mode? I doubt gevent is compatible with that, whatever you do with hardware is likely blocking.

– Miguel
Mar 6 at 21:27





Are you also using GPIO when you run in debug mode? I doubt gevent is compatible with that, whatever you do with hardware is likely blocking.

– Miguel
Mar 6 at 21:27













Yes I run the exact same code with the GPIO. It works in debug and hang when debug is set to False... I also tried with evenlet and same thing happend.

– Nicolas Foisy
Mar 6 at 22:01






Yes I run the exact same code with the GPIO. It works in debug and hang when debug is set to False... I also tried with evenlet and same thing happend.

– Nicolas Foisy
Mar 6 at 22:01














@Miguel If I run socketio = SocketIO(app, async_mode='threading') and debug=False it also works with long polling.

– Nicolas Foisy
Mar 6 at 22:09





@Miguel If I run socketio = SocketIO(app, async_mode='threading') and debug=False it also works with long polling.

– Nicolas Foisy
Mar 6 at 22:09












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024462%2fflask-socketio-with-gevent-not-working-when-debug-false%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55024462%2fflask-socketio-with-gevent-not-working-when-debug-false%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко