I'm trying to use flask-socketio to handle the communications between a server and a client. The server code can be boiled down to this:
from multiprocessing import Process, freeze_support
import eventlet
eventlet.monkey_patch()
freeze_support()
from flask_socketio import SocketIO
from flask import Flask, request, session
from time import time
app = Flask(__name__)
sio = SocketIO(app, logger=True, engineio_logger=True, async_mode='eventlet')
@sio.on('create_process')
def create_process():
test_process = Process(target=process_stuff)
test_process.start()
def process_stuff():
print("Process Initialized")
start_time = time()
while time() - start_time < 60:
# process stuff
continue
print("Process Terminated")
sio.run(app, "0.0.0.0", 8000)
It's all working perfectly at the beginning but, after some time, multiprocessing stops creating new processes. The server, however, continues to receive events. I have also tried using gevent async_mode but this didn't fix the problem.
My actual script never sends or handles events directly in the processes, it's completely separate. Is this still some sort of limitation with using multiprocessing and flask-socketio?