Skip to content

Commit

Permalink
Trap and log fetch_collection exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwatson committed May 10, 2024
1 parent 41322eb commit d8aa73c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
26 changes: 13 additions & 13 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ asgiref==3.8.1
attrs==23.2.0
# via aiohttp
blurhash-python==1.2.2
boto3==1.34.91
boto3==1.34.102
# via django-storages
botocore==1.34.91
botocore==1.34.102
# via boto3
# via s3transfer
cachetools==5.3.3
Expand All @@ -44,14 +44,14 @@ charset-normalizer==3.3.2
# via requests
click==8.1.7
# via uvicorn
cryptography==42.0.5
cryptography==42.0.7
# via http-ece
# via py-vapid
# via pywebpush
distlib==0.3.8
# via virtualenv
dj-database-url==2.1.0
django==4.2.11
django==4.2.13
# via dj-database-url
# via django-cors-headers
# via django-debug-toolbar
Expand All @@ -61,19 +61,19 @@ django-cache-url==3.4.5
django-cors-headers==4.3.1
django-debug-toolbar==4.3.0
django-htmx==1.17.3
django-storages==1.14.2
django-storages==1.14.3
dnspython==2.6.1
# via email-validator
email-validator==2.1.1
# via pydantic
filelock==3.13.4
filelock==3.14.0
# via virtualenv
frozendict==2.4.2
frozendict==2.4.4
# via pyld
frozenlist==1.4.1
# via aiohttp
# via aiosignal
google-api-core==2.18.0
google-api-core==2.19.0
# via google-cloud-core
# via google-cloud-storage
google-auth==2.29.0
Expand Down Expand Up @@ -141,8 +141,8 @@ protobuf==4.25.3
# via google-api-core
# via googleapis-common-protos
# via proto-plus
psycopg==3.1.18
psycopg-binary==3.1.18
psycopg==3.1.19
psycopg-binary==3.1.19
# via psycopg
py-vapid==1.9.0
# via pywebpush
Expand All @@ -161,7 +161,7 @@ pydantic-core==2.18.2
pydantic-settings==2.2.1
pyld==2.0.4
pymemcache==4.0.0
pytest==8.1.1
pytest==8.2.0
# via pytest-asyncio
# via pytest-django
# via pytest-dotenv
Expand All @@ -187,7 +187,7 @@ rsa==4.9
# via google-auth
s3transfer==0.10.1
# via boto3
sentry-sdk==1.45.0
sentry-sdk==2.1.1
setuptools==69.5.1
# via nodeenv
six==1.16.0
Expand All @@ -211,7 +211,7 @@ urllib3==2.2.1
# via sentry-sdk
urlman==2.0.1
uvicorn==0.29.0
virtualenv==20.26.0
virtualenv==20.26.1
# via pre-commit
whitenoise==6.6.0
yarl==1.9.4
Expand Down
20 changes: 10 additions & 10 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ asgiref==3.8.1
attrs==23.2.0
# via aiohttp
blurhash-python==1.2.2
boto3==1.34.91
boto3==1.34.102
# via django-storages
botocore==1.34.91
botocore==1.34.102
# via boto3
# via s3transfer
cachetools==5.3.3
Expand All @@ -42,12 +42,12 @@ charset-normalizer==3.3.2
# via requests
click==8.1.7
# via uvicorn
cryptography==42.0.5
cryptography==42.0.7
# via http-ece
# via py-vapid
# via pywebpush
dj-database-url==2.1.0
django==4.2.11
django==4.2.13
# via dj-database-url
# via django-cors-headers
# via django-debug-toolbar
Expand All @@ -57,17 +57,17 @@ django-cache-url==3.4.5
django-cors-headers==4.3.1
django-debug-toolbar==4.3.0
django-htmx==1.17.3
django-storages==1.14.2
django-storages==1.14.3
dnspython==2.6.1
# via email-validator
email-validator==2.1.1
# via pydantic
frozendict==2.4.2
frozendict==2.4.4
# via pyld
frozenlist==1.4.1
# via aiohttp
# via aiosignal
google-api-core==2.18.0
google-api-core==2.19.0
# via google-cloud-core
# via google-cloud-storage
google-auth==2.29.0
Expand Down Expand Up @@ -121,8 +121,8 @@ protobuf==4.25.3
# via google-api-core
# via googleapis-common-protos
# via proto-plus
psycopg==3.1.18
psycopg-binary==3.1.18
psycopg==3.1.19
psycopg-binary==3.1.19
# via psycopg
py-vapid==1.9.0
# via pywebpush
Expand Down Expand Up @@ -155,7 +155,7 @@ rsa==4.9
# via google-auth
s3transfer==0.10.1
# via boto3
sentry-sdk==1.45.0
sentry-sdk==2.1.1
six==1.16.0
# via blurhash-python
# via python-dateutil
Expand Down
2 changes: 1 addition & 1 deletion users/models/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class IdentityStates(StateGraph):
"""

outdated = State(try_interval=3600, force_initial=True)
updated = State(try_interval=86400 * 15, attempt_immediately=False)
updated = State(try_interval=86400 * 7, attempt_immediately=False)

edited = State(try_interval=300, attempt_immediately=True)
deleted = State(try_interval=300, attempt_immediately=True)
Expand Down
10 changes: 7 additions & 3 deletions users/services/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,16 @@ def handle_internal_sync_actor(cls, payload):
# Do all the fetching in threads using a single client
for fn, url, action in pipeline:
if url:
future_actions[pool.submit(fn, client, url)] = action
future_actions[pool.submit(fn, client, url)] = (action, url)
# Re-submit the updates to happen in threads as well
for f in concurrent.futures.as_completed(future_actions):
pool.submit(future_actions[f], f.result())
action, url = future_actions[f]
try:
pool.submit(action, f.result())
except ValueError:
logger.exception("Error fetching %s", url)
# Wait for everything to finish
pool.shutdown()
logger.info("SYNC %s", stats)
logger.info("SYNC %s: %s", actor.actor_uri, stats)
actor.stats = stats
actor.save(update_fields=["stats"])

0 comments on commit d8aa73c

Please sign in to comment.