Skip to content

Commit

Permalink
fix: gevent uncompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan-Computas committed Sep 19, 2024
1 parent bd067b3 commit c625442
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ def create_app():
cors_allowed_origins=Keys.get("CORS_ALLOWED_ORIGIN"),
logger=True,
engineio_logger=False,
async_mode='gevent'
)
else:
socketio.init_app(
app, cors_allowed_origins="*", logger=True, engineio_logger=False
app, cors_allowed_origins="*", logger=True, engineio_logger=False, async_mode='gevent'
)
CORS(
app,
Expand Down
30 changes: 17 additions & 13 deletions src/singleplayer/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from flask import Blueprint, current_app, request, session
from werkzeug.security import generate_password_hash, check_password_hash
from werkzeug import exceptions as excp
import traceback


singleplayer = Blueprint("singleplayer", __name__)
Expand Down Expand Up @@ -222,19 +223,22 @@ def get_n_drawings_by_label():
"""
Returns n images from the blob storage container with the given label.
"""
data = request.get_json()
number_of_images = data["number_of_images"]
label = data["label"]
lang = data["lang"]
if lang == "NO":
label = shared_models.to_english(label)

image_urls = shared_models.get_n_random_example_images(
label, number_of_images
)
images = storage.get_images_from_relative_url(image_urls)
return json.dumps(images), 200

try:
data = request.get_json()
number_of_images = data["number_of_images"]
label = data["label"]
lang = data["lang"]
if lang == "NO":
label = shared_models.to_english(label)

image_urls = shared_models.get_n_random_example_images(
label, number_of_images
)
images = storage.get_images_from_relative_url(image_urls)
return json.dumps(images), 200
except RecursionError as e:
current_app.logger.error("RecursionError: " + str(e))
traceback.print_stack()

@singleplayer.route("/auth", methods=["POST"])
def authenticate():
Expand Down

0 comments on commit c625442

Please sign in to comment.