Skip to content

Commit

Permalink
refactor: remove version_utils and threadings_utils, integrate gevent…
Browse files Browse the repository at this point in the history
… patching directly in app.py

Signed-off-by: -LAN- <laipz8200@outlook.com>
  • Loading branch information
laipz8200 committed Dec 29, 2024
1 parent 253c58e commit 4720485
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 39 deletions.
20 changes: 12 additions & 8 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from libs import version_utils

# preparation before creating app
version_utils.check_supported_python_version()
import os
import sys


def is_db_command():
import sys

if len(sys.argv) > 1 and sys.argv[0].endswith("flask") and sys.argv[1] == "db":
return True
return False
Expand All @@ -19,9 +15,17 @@ def is_db_command():
app = create_migrations_app()
else:
from app_factory import create_app
from libs import threadings_utils

threadings_utils.apply_gevent_threading_patch()
if not os.environ.get("DEBUG", False):
from gevent import monkey # type: ignore

# gevent
monkey.patch_all()

from grpc.experimental import gevent as grpc_gevent # type: ignore

# grpc gevent
grpc_gevent.init_gevent()

app = create_app()
celery = app.extensions["celery"]
Expand Down
19 changes: 0 additions & 19 deletions api/libs/threadings_utils.py

This file was deleted.

12 changes: 0 additions & 12 deletions api/libs/version_utils.py

This file was deleted.

0 comments on commit 4720485

Please sign in to comment.