本文整理匯總了Python中mo_threads.Thread.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python Thread.__init__方法的具體用法?Python Thread.__init__怎麽用?Python Thread.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mo_threads.Thread
的用法示例。
在下文中一共展示了Thread.__init__方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from mo_threads import Thread [as 別名]
# 或者: from mo_threads.Thread import __init__ [as 別名]
def __init__(
self,
exchange, # name of the Pulse exchange
topic, # message name pattern to subscribe to ('#' is wildcard)
target=None, # WILL BE CALLED WITH PULSE PAYLOADS AND ack() IF COMPLETE$ED WITHOUT EXCEPTION
target_queue=None, # (aka self.queue) WILL BE FILLED WITH PULSE PAYLOADS
host='pulse.mozilla.org', # url to connect,
port=5671, # tcp port
user=None,
password=None,
vhost="/",
start=0, # USED AS STARTING POINT FOR ASSIGNING THE _meta.count ATTRIBUTE
ssl=True,
applabel=None,
heartbeat=False, # True to also get the Pulse heartbeat message
durable=False, # True to keep queue after shutdown
serializer='json',
broker_timezone='GMT',
kwargs=None
):
global count
count = coalesce(start, 0)
self.target_queue = target_queue
self.pulse_target = target
if (target_queue == None and target == None) or (target_queue != None and target != None):
Log.error("Expecting a queue (for fast digesters) or a target (for slow digesters)")
Thread.__init__(self, name="Pulse consumer for " + kwargs.exchange, target=self._worker)
self.settings = kwargs
kwargs.callback = self._got_result
kwargs.user = coalesce(kwargs.user, kwargs.username)
kwargs.applabel = coalesce(kwargs.applable, kwargs.queue, kwargs.queue_name)
kwargs.topic = topic
self.pulse = ModifiedGenericConsumer(kwargs, connect=True, **kwargs)
self.start()