Skip to content

Commit

Permalink
Merge pull request #15 from dgnorth/feature/gevent
Browse files Browse the repository at this point in the history
Feature/gevent
  • Loading branch information
judgeaxl authored Jul 13, 2020
2 parents 223074e + 1346f9e commit 7b5d420
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ greenlet = "*"
python-decouple = "*"
flask-restx = "*"
python-driftconfig = "*"
psycogreen = "*"

[dev-packages]
pytest = "*"
Expand Down
21 changes: 14 additions & 7 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions config/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
[uwsgi]
# Accept only valid configuration options
strict = true

# Process management info
threads = 4
#gevent = 100
master = true
single-interpreter = true
need-app = true
auto-procname = true
procname-prefix = "drift-base "
die-on-term = true
vacuum = true
uid = uwsgi
cheaper = 2
workers = %(4 * %k)
# max-worker-lifetime = 600
idle = true
pidfile = /tmp/uwsgi.pid

# Threading management info
enable-threads = true
threads = without
gevent = 1000
workers = %(1 * %k)

# Application info
module=drift.contrib.flask.plainapp:app
module=driftbase.flask.driftbaseapp:app

# Web servers for nginx reverse proxy, local testing and uwsgitop.
# Number of listening sockets set to a rather high number.
Expand Down
3 changes: 0 additions & 3 deletions driftbase/api/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ def get(self, exchange, exchange_id):

args = self.get_args.parse_args()
timeout = args.timeout or 0
#! Set timeout to 0 to disable long polling until we can
#! get gevent up and running in uwsgi.
timeout = 0
min_message_number = int(args.messages_after or 0) + 1
rows = args.rows
if rows:
Expand Down
Empty file added driftbase/flask/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions driftbase/flask/driftbaseapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Flask app with gevent monkey patching.
"""
import logging

from gevent import monkey
monkey.patch_all()
from psycogreen.gevent import patch_psycopg
patch_psycopg()

from drift.flaskfactory import drift_app

app = drift_app()

0 comments on commit 7b5d420

Please sign in to comment.