Closed BuckLearnsCode closed 11 months ago
Please do not write issues when you have a question about your own application. The issues board helps me track bugs in this package. Use the discussions board to ask questions or seek help.
With regards to your problem, gevent does not work with async def
, you are confusing two different asynchronous solutions that do not work with each other.
Hey, I'm new to coding, but feel like I've gotten a total crash course while trying to get the following working:
I have 'gevent' added to async_mode. I'm spawning greenlets.
My issue is that as soon as I switch a function to async, it won't enter the function. I can't figure out what's wrong and neither can chatgpt. I've been working on this for 3 days, I figured I'd ask.
Notes:
from gevent import monkey, get_hub, spawn, getcurrent import gevent monkey.patch_all() from flask import Flask, request from flask_socketio import join_room, SocketIO from flask_cors import CORS
app = Flask(name, static_folder="front/build", static_url_path="/") socketio = SocketIO( app, cors_allowed_origins="*", load_balancer=True, engineio_logger=True, logger=True, async_mode='gevent' )
@socketio.on("send_message", namespace=GAME_NAMESPACE) async def handle_message(data): print(Fore.RED + 'Handle Message Accessed.') print(f"Current Thread ID: {getcurrent()}") try: user_input = data["message"] user_inputs_buffer.append(user_input)
if name == "main": port = int(os.environ.get("PORT", 5001)) socketio.run(app, host="127.0.0.1", port=port, debug=True)