Skip to content

Commit

Permalink
Wait for queues
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-piles committed Nov 11, 2024
1 parent b5145f8 commit be295f3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ jobs:
timeout: 240000
interval: 500

- name: Wait for queues
run: make wait_for_queues

- name: Test with unittest
run: make test
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ check_format:
test:
. .venv/bin/activate; command cd src; command python -m pytest

wait_for_queues:
. .venv/bin/activate; command cd src/scripts; command python wait_for_queues.py

remove_docker_containers:
docker compose ps -q | xargs docker rm

Expand Down
28 changes: 28 additions & 0 deletions src/scripts/wait_for_queues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from time import sleep

from rsmq import RedisSMQ

REDIS_HOST = "127.0.0.1"
REDIS_PORT = "6379"


def wait_for_queues():
queue = RedisSMQ(
host=REDIS_HOST,
port=REDIS_PORT,
qname="information_extraction_tasks",
quiet=False,
)

for i in range(60):
try:
queue.getQueueAttributes().exec_command()
print("Queue is ready")
return
except:
print("Waiting for queue")
sleep(5)


if __name__ == "__main__":
wait_for_queues()

0 comments on commit be295f3

Please sign in to comment.