Skip to content

Commit

Permalink
Fix cyclic import with a new file
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwaizer committed Dec 9, 2024
1 parent 0d15f26 commit 154875a
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 13 deletions.
5 changes: 1 addition & 4 deletions alws/dramatiq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
and it's important for all tasks which involves user interaction
to have priority 0.
4. If you need to use async function in your dramatiq task - ALWAYS use
loop from this __init__.py, since creating multiple loops for tasks
loop from this _event_loop.py, since creating multiple loops for tasks
will break your tasks.
"""

import asyncio

import dramatiq
from dramatiq.brokers.rabbitmq import RabbitmqBroker

Expand All @@ -27,7 +25,6 @@
f"{settings.rabbitmq_default_vhost}",
)
dramatiq.set_broker(rabbitmq_broker)
event_loop = asyncio.get_event_loop()

# Tasks import started from here
from alws.dramatiq.build import build_done, start_build
Expand Down
3 changes: 3 additions & 0 deletions alws/dramatiq/_event_loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import asyncio

event_loop = asyncio.get_event_loop()
2 changes: 1 addition & 1 deletion alws/dramatiq/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from alws.crud import build_node as build_node_crud
from alws.crud import test
from alws.dependencies import get_async_db_key
from alws.dramatiq import event_loop
from alws.dramatiq._event_loop import event_loop
from alws.errors import (
ArtifactConversionError,
ModuleUpdateError,
Expand Down
2 changes: 1 addition & 1 deletion alws/dramatiq/errata.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
release_new_errata_record,
reset_matched_erratas_packages_threshold,
)
from alws.dramatiq import event_loop
from alws.dramatiq._event_loop import event_loop
from alws.utils.fastapi_sqla_setup import setup_all

__all__ = ["release_errata"]
Expand Down
2 changes: 1 addition & 1 deletion alws/dramatiq/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from alws.config import settings
from alws.constants import DRAMATIQ_TASK_TIMEOUT, BuildTaskStatus
from alws.dependencies import get_async_db_key
from alws.dramatiq import event_loop
from alws.dramatiq._event_loop import event_loop
from alws.utils.fastapi_sqla_setup import setup_all
from alws.utils.log_utils import setup_logger
from alws.utils.pulp_client import PulpClient
Expand Down
4 changes: 1 addition & 3 deletions alws/dramatiq/releases.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from contextlib import asynccontextmanager

import dramatiq
from fastapi_sqla import open_async_session

from alws.constants import DRAMATIQ_TASK_TIMEOUT
from alws.crud import release as r_crud
from alws.dependencies import get_async_db_key
from alws.dramatiq import event_loop
from alws.dramatiq._event_loop import event_loop
from alws.utils.fastapi_sqla_setup import setup_all

__all__ = ["execute_release_plan"]
Expand Down
2 changes: 1 addition & 1 deletion alws/dramatiq/sign_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from alws.constants import DRAMATIQ_TASK_TIMEOUT
from alws.crud import sign_task
from alws.dramatiq import event_loop
from alws.dramatiq._event_loop import event_loop
from alws.schemas import sign_schema
from alws.utils.fastapi_sqla_setup import setup_all

Expand Down
2 changes: 1 addition & 1 deletion alws/dramatiq/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from alws.constants import DRAMATIQ_TASK_TIMEOUT, TestTaskStatus
from alws.crud import test as t_crud
from alws.dependencies import get_async_db_key
from alws.dramatiq import event_loop
from alws.dramatiq._event_loop import event_loop
from alws.schemas.test_schema import TestTaskResult
from alws.utils.fastapi_sqla_setup import setup_all

Expand Down
2 changes: 1 addition & 1 deletion alws/dramatiq/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from alws.constants import DRAMATIQ_TASK_TIMEOUT
from alws.crud import build as build_crud
from alws.dependencies import get_async_db_key
from alws.dramatiq import event_loop
from alws.dramatiq._event_loop import event_loop
from alws.utils.fastapi_sqla_setup import setup_all

__all__ = ['perform_user_removal']
Expand Down

0 comments on commit 154875a

Please sign in to comment.