Initial commit: AuroraMusic monorepo
This commit is contained in:
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
import logging
|
||||
|
||||
from rq import Worker, get_current_connection
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def cleanup_ghosts(conn=None, worker_class=Worker):
|
||||
"""
|
||||
RQ versions < 0.3.6 suffered from a race condition where workers, when
|
||||
abruptly terminated, did not have a chance to clean up their worker
|
||||
registration, leading to reports of ghosted workers in `rqinfo`. Since
|
||||
0.3.6, new worker registrations automatically expire, and the worker will
|
||||
make sure to refresh the registrations as long as it's alive.
|
||||
|
||||
This function will clean up any of such legacy ghosted workers.
|
||||
"""
|
||||
conn = conn if conn else get_current_connection()
|
||||
for worker in worker_class.all(connection=conn):
|
||||
if conn.ttl(worker.key) == -1:
|
||||
ttl = worker.worker_ttl
|
||||
conn.expire(worker.key, ttl)
|
||||
logger.info('Marked ghosted worker {0} to expire in {1} seconds.'.format(worker.name, ttl))
|
||||
@@ -0,0 +1,8 @@
|
||||
def register_sentry(sentry_dsn, **opts):
|
||||
"""Given a Raven client and an RQ worker, registers exception handlers
|
||||
with the worker so exceptions are logged to Sentry.
|
||||
"""
|
||||
import sentry_sdk
|
||||
from sentry_sdk.integrations.rq import RqIntegration
|
||||
|
||||
sentry_sdk.init(sentry_dsn, integrations=[RqIntegration()], **opts)
|
||||
Reference in New Issue
Block a user