當前位置: 首頁>>代碼示例>>Python>>正文


Python Receiver.connect方法代碼示例

本文整理匯總了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()
開發者ID:AzharWeb,項目名稱:sandbox,代碼行數:13,代碼來源:program.py

示例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()
開發者ID:fangbei,項目名稱:email_robot,代碼行數:33,代碼來源:main.py


注:本文中的receiver.Receiver.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。