Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cyclic import #1084

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion alws/routers/releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from fastapi import APIRouter, Depends
from fastapi_sqla import AsyncSessionDependency
from sqlalchemy import update
from sqlalchemy import select, update
from sqlalchemy.ext.asyncio import AsyncSession

from alws import models
Expand Down
Loading