本文整理匯總了Python中receiver.Receiver.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python Receiver.connect方法的具體用法?Python Receiver.connect怎麽用?Python Receiver.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類receiver.Receiver
的用法示例。
在下文中一共展示了Receiver.connect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from receiver import Receiver [as 別名]
# 或者: from receiver.Receiver import connect [as 別名]
def main():
sender = Sender('localhost')
sender.connect()
sender.create_queue('inbox')
sender.send_message('inbox', 'hello')
sender.disconnect()
receiver = Receiver('localhost')
receiver.connect()
receiver.receive('inbox')
receiver.disconnect()
示例2: InitLogging
# 需要導入模塊: from receiver import Receiver [as 別名]
# 或者: from receiver.Receiver import connect [as 別名]
format="%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
filename=filename,
filemode="w")
console = logging.StreamHandler()
console.setLevel(logging.NOTSET)
formatter = logging.Formatter("%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s")
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
if __name__ == '__main__':
InitLogging()
handler = Handler()
receiver = Receiver()
transmitter = Transmitter()
receiver.connect()
td1 = threading.Thread(target=handler.run)
td2 = threading.Thread(target=receiver.run)
td3 = threading.Thread(target=transmitter.run)
td1.start()
td2.start()
td3.start()
# main loop
while True:
if handler.is_runing() and receiver.is_runing() and transmitter.is_runing():
msg = receiver.fetch()
while msg != None:
handler.push(msg)
msg = receiver.fetch()