Skip to content

Commit

Permalink
optimize work horse initialization by configuration mappers on the wo…
Browse files Browse the repository at this point in the history
…rker process (#4314)
  • Loading branch information
Omer Lachish authored Oct 30, 2019
1 parent 82f488d commit 36638be
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redash/cli/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from click import argument
from flask.cli import AppGroup
from rq import Connection, Worker
from sqlalchemy.orm import configure_mappers

from redash import rq_redis_connection
from redash.schedule import rq_scheduler, schedule_periodic_jobs
Expand All @@ -22,6 +23,11 @@ def scheduler():
@manager.command()
@argument('queues', nargs=-1)
def worker(queues='default'):
# Configure any SQLAlchemy mappers loaded until now so that the mapping configuration
# will already be available to the forked work horses and they won't need
# to spend valuable time re-doing that on every fork.
configure_mappers()

if not queues:
queues = ('default',)
with Connection(rq_redis_connection):
Expand Down

0 comments on commit 36638be

Please sign in to comment.