Skip to content

Commit 2a521e5

Browse files
committed
chore(queue): import directly instead of using strings and importlib
1 parent 70e9218 commit 2a521e5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

polytope_server/common/queue/queue.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
# does it submit to any jurisdiction.
1919
#
2020

21-
import importlib
2221
from abc import ABC, abstractmethod
2322

23+
from polytope_server.common.queue.rabbitmq_queue import RabbitmqQueue
24+
from polytope_server.common.queue.sqs_queue import SQSQueue
25+
2426

2527
class Message:
2628
def __init__(self, body, context=None):
@@ -70,12 +72,9 @@ def get_type(self) -> str:
7072
"""Get the implementation type"""
7173

7274

73-
queue_dict = {"rabbitmq": "RabbitmqQueue", "sqs": "SQSQueue"}
75+
queue_types = {"rabbitmq": RabbitmqQueue, "sqs": SQSQueue}
7476

7577

7678
def create_queue(queue_config) -> Queue:
77-
7879
queue_type = next(iter(queue_config.keys()), "rabbitmq")
79-
80-
QueueClass = importlib.import_module("polytope_server.common.queue." + queue_type + "_queue")
81-
return getattr(QueueClass, queue_dict[queue_type])(queue_config[queue_type])
80+
return queue_types[queue_type](queue_config[queue_type])

0 commit comments

Comments
 (0)