def __init__(self, app_id, **kwargs):
"""
Initialize broker connection.
:param app_id: string that identifies application
"""
self.app_id = app_id
# fetch configuration
if "url" in kwargs:
self.rabbitmq_url = kwargs['url']
else:
self.rabbitmq_url = os.environ.get("broker_host", RABBITMQ_URL_FALLBACK)
self.rabbitmq_exchange = os.environ.get("broker_exchange", RABBITMQ_EXCHANGE_FALLBACK)
self.rabbitmq_exchange_type = "topic"
# create additional members
self._connection = None
# trigger connection setup (without blocking)
self.setup_connection()
# Threading workers
self.thrd_pool = pool.ThreadPoolExecutor(max_workers=100)
# Track the workers
self.tasks = []
评论列表
文章目录