Skip to content

Commit b708c09

Browse files
committed
Fix cyclic import with a new file
1 parent 3462efb commit b708c09

File tree

9 files changed

+11
-13
lines changed

9 files changed

+11
-13
lines changed

alws/dramatiq/__init__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
and it's important for all tasks which involves user interaction
99
to have priority 0.
1010
4. If you need to use async function in your dramatiq task - ALWAYS use
11-
loop from this __init__.py, since creating multiple loops for tasks
11+
loop from this _event_loop.py, since creating multiple loops for tasks
1212
will break your tasks.
1313
"""
1414

15-
import asyncio
16-
1715
import dramatiq
1816
from dramatiq.brokers.rabbitmq import RabbitmqBroker
1917

@@ -27,7 +25,6 @@
2725
f"{settings.rabbitmq_default_vhost}",
2826
)
2927
dramatiq.set_broker(rabbitmq_broker)
30-
event_loop = asyncio.get_event_loop()
3128

3229
# Tasks import started from here
3330
from alws.dramatiq.build import build_done, start_build

alws/dramatiq/_event_loop.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import asyncio
2+
3+
event_loop = asyncio.get_event_loop()

alws/dramatiq/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from alws.crud import build_node as build_node_crud
2222
from alws.crud import test
2323
from alws.dependencies import get_async_db_key
24-
from alws.dramatiq import event_loop
24+
from alws.dramatiq._event_loop import event_loop
2525
from alws.errors import (
2626
ArtifactConversionError,
2727
ModuleUpdateError,

alws/dramatiq/errata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
release_new_errata_record,
1111
reset_matched_erratas_packages_threshold,
1212
)
13-
from alws.dramatiq import event_loop
13+
from alws.dramatiq._event_loop import event_loop
1414
from alws.utils.fastapi_sqla_setup import setup_all
1515

1616
__all__ = ["release_errata"]

alws/dramatiq/products.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from alws.config import settings
1414
from alws.constants import DRAMATIQ_TASK_TIMEOUT, BuildTaskStatus
1515
from alws.dependencies import get_async_db_key
16-
from alws.dramatiq import event_loop
16+
from alws.dramatiq._event_loop import event_loop
1717
from alws.utils.fastapi_sqla_setup import setup_all
1818
from alws.utils.log_utils import setup_logger
1919
from alws.utils.pulp_client import PulpClient

alws/dramatiq/releases.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
from contextlib import asynccontextmanager
2-
31
import dramatiq
42
from fastapi_sqla import open_async_session
53

64
from alws.constants import DRAMATIQ_TASK_TIMEOUT
75
from alws.crud import release as r_crud
86
from alws.dependencies import get_async_db_key
9-
from alws.dramatiq import event_loop
7+
from alws.dramatiq._event_loop import event_loop
108
from alws.utils.fastapi_sqla_setup import setup_all
119

1210
__all__ = ["execute_release_plan"]

alws/dramatiq/sign_task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from alws.constants import DRAMATIQ_TASK_TIMEOUT
66
from alws.crud import sign_task
7-
from alws.dramatiq import event_loop
7+
from alws.dramatiq._event_loop import event_loop
88
from alws.schemas import sign_schema
99
from alws.utils.fastapi_sqla_setup import setup_all
1010

alws/dramatiq/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from alws.constants import DRAMATIQ_TASK_TIMEOUT, TestTaskStatus
88
from alws.crud import test as t_crud
99
from alws.dependencies import get_async_db_key
10-
from alws.dramatiq import event_loop
10+
from alws.dramatiq._event_loop import event_loop
1111
from alws.schemas.test_schema import TestTaskResult
1212
from alws.utils.fastapi_sqla_setup import setup_all
1313

alws/dramatiq/user.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from alws.constants import DRAMATIQ_TASK_TIMEOUT
88
from alws.crud import build as build_crud
99
from alws.dependencies import get_async_db_key
10-
from alws.dramatiq import event_loop
10+
from alws.dramatiq._event_loop import event_loop
1111
from alws.utils.fastapi_sqla_setup import setup_all
1212

1313
__all__ = ['perform_user_removal']

0 commit comments

Comments
 (0)