-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d62db9f
commit 2478709
Showing
6 changed files
with
33 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
import logging | ||
from rq import Worker, Queue, Connection | ||
from rq import Worker, Queue | ||
from dotenv import load_dotenv | ||
from app import create_app | ||
|
||
# Load environment variables | ||
load_dotenv() | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
if __name__ == '__main__': | ||
# Configure logger | ||
logger = logging.getLogger(__name__) | ||
|
||
if __name__ == "__main__": | ||
# Create Flask application and load configuration | ||
app = create_app() | ||
|
||
with app.app_context(): | ||
# Create Flask application and load configuration | ||
redis_connection = app.config["SESSION_REDIS"] | ||
|
||
# Define the queues to be listened to | ||
listen = ["default"] | ||
|
||
# Connect to Redis and start listening to the queue | ||
listen = ['default'] | ||
conn = app.config['SESSION_REDIS'] | ||
# Create queue list | ||
queues = [Queue(name, connection=redis_connection) for name in listen] | ||
|
||
with Connection(conn): | ||
worker = Worker(list(map(Queue, listen))) | ||
worker.work() | ||
# Initialise the worker | ||
logger.info(f"Starting worker for queues: {listen}") | ||
worker = Worker(queues) | ||
worker.work() |