Skip to content

Commit 1a6a2bd

Browse files
committed
feat(gunicorn): use process replace threads
1 parent 2953cc7 commit 1a6a2bd

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

rootfs/api/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ def async_run(tasks):
154154
return
155155

156156
# start a new async event loop
157-
loop = asyncio.new_event_loop()
158-
asyncio.set_event_loop(loop)
157+
loop = asyncio.get_event_loop()
159158
# https://github.com/python/asyncio/issues/258
160159
executor = concurrent.futures.ThreadPoolExecutor(5)
161160
loop.set_default_executor(executor)

rootfs/drycc/gunicorn/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import os
12
from os.path import dirname, realpath
23
from multiprocessing import cpu_count
34

45
import faulthandler
56
faulthandler.enable()
67

78
bind = '0.0.0.0'
8-
workers = 1
9-
threads = cpu_count() * 4 + 1
9+
workers = int(os.environ.get('GUNICORN_WORKERS', cpu_count() * 4 + 1))
1010

1111
pythonpath = dirname(dirname(dirname(realpath(__file__))))
1212
timeout = 1200

0 commit comments

Comments
 (0)