Skip to content

Commit

Permalink
fix issues with celery tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed May 31, 2024
1 parent a562b48 commit 3a86023
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import os
import subprocess
import time

Expand All @@ -24,19 +23,19 @@ def setup() -> Generator[None, None, None]:
# # Sleep for 5 seconds
# time.sleep(5)

# Change directory to `tests/`
os.chdir("tests/")

# Start the Celery worker
celery_process = subprocess.Popen(
["celery", "-A", "celery_tasks", "worker", "--loglevel=debug"]
[
"celery",
"-A",
"tests.celery_tasks",
"worker",
"--loglevel=debug",
],
)

time.sleep(5)

# Change directory back to the original
os.chdir("..")

yield

finally:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_task_celery_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_chord_tasks( # type: ignore
seconds = kwargs.get("seconds")
task_id = kwargs.get("task_id")
return (
[task_sleep.s(seconds, task_id, task_id)],
[task_sleep.s(seconds, task_id)],
None,
)

Expand Down Expand Up @@ -76,7 +76,7 @@ def test_serial_result(self, task_result: Task) -> None:
results[task_id] = i + i

for task_id, expected in results.items():
result = task.result.get(task_id, timeout=10)
result = task.result.get(task_id, timeout=10)[0]
assert (
result == expected
), f"Expected Result: {expected}, Actual Result: {result}"
Expand Down

0 comments on commit 3a86023

Please sign in to comment.