Skip to content

Commit fa303a0

Browse files
authored
Restart workers after 10000 requests, move cache size to envvar (#77)
* Restart workers after 10000 requests, move cache size to envvar * Lint fixes
1 parent 0ae466a commit fa303a0

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Procfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: gunicorn profbit.app:app --log-file=- --timeout=20 --worker-connections=4 --worker-class=gevent
1+
web: gunicorn profbit.app:app --log-file=- --timeout=20 --worker-connections=4 --worker-class=gevent --max-requests=10000

profbit/coinbase_stats.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from coinbase.wallet.client import OAuthClient
1010

11+
from .app import app
1112
from .currency_map import CURRENCY_MAP
1213

1314
TIMESTAMP_REGEX = re.compile(
@@ -287,7 +288,7 @@ def _get_total_data(client, accounts):
287288
return stats
288289

289290

290-
@lru_cache(maxsize=256)
291+
@lru_cache(maxsize=app.config.get('CACHE_SIZE'))
291292
def _get_user_and_accounts(access_token, cache_date):
292293
"""
293294
We cache API calls for the Coinbase `User` object and account data,

profbit/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
GOOGLE_ANALYTICS_ID = os.environ.get('GOOGLE_ANALYTICS_ID', '')
1010
SB_AGENT_ID = os.environ.get('SB_AGENT_ID', '')
1111
CONTACT_EMAIL = os.environ.get('CONTACT_EMAIL', '')
12+
CACHE_SIZE = int(os.environ.get('CACHE_SIZE', 128))
1213

1314
# For templates
1415
LOGIN_URL = "/login/coinbase/?remember_me=1"

0 commit comments

Comments
 (0)