特定时间后的扭曲电抗器

2024-06-07 22:16:05 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有办法在特定时间后,例如10分钟,通过reactor.stop()reactor.callFromThread(reactor.stop)停止{}

样品:

import sys
from twisted.python import log
from twisted.internet import reactor, task
from twisted.internet.defer import Deferred, DeferredList
from autobahn.twisted.websocket import connectWS
from protocol import WampClientFactory, WampClientProtocol

class SMSManagementProtocol(WampClientProtocol):
    def showEvent(self, topicUri, result):
        print "EVENT:", topicUri,result
    def onSessionOpen(self):
        self.prefix("event", "http://test.tv/subscribe_public")
        self.subscribe('psevent:on_sms_delivered', self.showEvent)
        self.publish("event:send_sms", {'sms_text':'test','phone_number':29999999,'user_name':'test'})

if __name__ == '__main__':
    sms_factory = WampClientFactory("ws://xx.xx.xxx.x:xxxx", debugWamp = True)
    sms_factory.protocol = SMSManagementProtocol
    connectWS(sms_factory)
    reactor.run()

这样停反应堆有可能吗?在

^{pr2}$

Tags: fromtestimportselffactorytwistedsmsprotocol

热门问题