0

Anytime I sent a post request to /tts/say or any other post request, the background task stops. Why is that and most importantly, how can I stop this behavior? I wasn't able to find more useful information, so if you miss some information, just ask, and I will try to provide it as quickly as possible. In the pepper.py there is connection to a python2 script via the socket module over port 9999. Here's the code from the main app.py:

 import os from flask import Flask import flask from flask_socketio import SocketIO import pepper import config app = Flask(__name__) socketio = SocketIO(app) pepper = pepper.Pepper() @app.route('/') def main_get(): # put application's code here return flask.render_template( 'index.html', autonomous_life_options=pepper.get_autonomous_life_options(), apps=pepper.get_installed_apps(), postures=pepper.get_postures() ) @app.route('/tts/say', methods=['POST']) def tts_say(): text = flask.request.get_json()['text'] pepper.say(text) return flask.Response("OK", status=200) ... @socketio.on('connect') def handle_connect(): print('Client connected: ', flask.request.remote_addr) def send_updates(): while True: socketio.sleep(1) print("sending...") socketio.emit('update_values', { 'volume': pepper.get_volume(), 'tablet_brightness': pepper.get_tablet_brightness(), 'autonomous_life_state': pepper.get_autonomous_life(), 'battery_level': pepper.get_battery_level(), 'apps_is_running': pepper.apps_is_running }) if __name__ == '__main__': socketio.start_background_task(send_updates) socketio.run(app, **config.server_config_args) print("Server listening on port 5005") 

Edit:

I now suspect the socket connection out of pepper.py (import socket) as if I modify my code to be more like this example (https://github.com/miguelgrinberg/Flask-SocketIO/blob/main/example/app.py) it still doesn't work, but if I run it without the pepper.py (in a test file) it works. I think I got near to what causes the problem, but I still don't understand why and who to fix it.

3
  • The background task is independent of what requests the server receives. If it is stopping then it must be because of an error and not because of an incoming request. Check your log for stack traces. Commented Jan 14 at 10:16
  • @MiguelGrinberg Thanks, I thought so too. But in the logs there are no stack traces, nothing that says something happened. Maybe even the whole server stops working. Could it be a conflict of socket and the flask-socket-io server? As it correlates with the first send in the pepper.py's socket-client (from import socket). Commented Jan 15 at 7:52
  • I think you need to try to understand better what's happening and what's not working, because the server won't just stop working and stay silent unless it is hanging for some reason. If you are using eventlet or gevent you may want to remove all that in case you are having some weird greenlet related issue. Commented Jan 15 at 16:16

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.