Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- def WebFunc(outfrompipe, intopipe):
- global thread
- app = Flask(__name__)
- app.config['SECRET_KEY'] = 'secret!'
- socketio = SocketIO(app, async_mode=”eventlet”)
- thread = None
- thread_lock = Lock()
- @app.route('/')
- def index():
- return render_template('index.html', async_mode=socketio.async_mode)
- @socketio.on('my_event', namespace='/test')
- def test_msg(msg):
- # Receive a message from a web app
- print(“Received message”, msg)
- # Send this message to another process
- # THIS IS WHERE IT HANGS!!
- intopipe.send(msg)
- socketio.run(app, debug=False, host='0.0.0.0')
- #!/usr/bin/python3
- import webprocess as webproc
- import multiprocessing
- import time
- if __name__ == '__main__':
- multiprocessing.set_start_method('spawn')
- outfrompipe, intopipe = multiprocessing.Pipe()
- wf = multiprocessing.Process(name=”WebProc”, target=webproc.WebFunc,
- args=(outfrompipe, intopipe))
- wf.start()
- while True:
- message = outfrompipe.recv()
- print(message)
- time.sleep(1)
- wf.join()
Add Comment
Please, Sign In to add comment