本文整理汇总了Python中twisted.internet.task.LoopingCall.addErrback方法的典型用法代码示例。如果您正苦于以下问题:Python LoopingCall.addErrback方法的具体用法?Python LoopingCall.addErrback怎么用?Python LoopingCall.addErrback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.task.LoopingCall
的用法示例。
在下文中一共展示了LoopingCall.addErrback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_data_transfers
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import addErrback [as 别名]
def process_data_transfers(self):
if self.disable_data_transfer:
raise Exception("Data transfer disabled!")
def process_transfers_error(ret):
print("An unknown error occured in process_transfers deferred")
print(ret)
d = LoopingCall(
process_transfers,
self._data_transfer
).start(0.002, now=True)
d.addErrback(process_transfers_error)
示例2: process_data_transfers
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import addErrback [as 别名]
def process_data_transfers(self):
if self.disable_data_transfer:
raise Exception("Data transfer disabled!")
def process_transfers_error(ret):
txt = "An unknown error occured in process_transfers: %s"
_log.error(txt % repr(ret))
d = LoopingCall(
process_transfers,
self._data_transfer
).start(0.002, now=True)
d.addErrback(process_transfers_error)
示例3: schedule_looping_call
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import addErrback [as 别名]
def schedule_looping_call():
d = LoopingCall(handle_timeout).start(1, now=True)
d.addErrback(handle_errors)
return d
示例4: testTcp
# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import addErrback [as 别名]
email_address = '[email protected]'
def testTcp():
print 'TEST SOCKET!'
tcplocation = '9,1024,ok'
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(server_address)
sock.sendall(tcplocation)
data = sock.recv(96)
if data != 'Result:9,1':
raise Exception('server dead')
else:
sock.close()
def finish(result, pid):
print 'in finish: %s' %(str(result.value))
try:
sendMail(email_address, 'huahai', 'SERVER DEAD!!!', '服务器没有回应心跳包')
os.kill(int(pid), signal.SIGKILL)
except Exception as e:
print e
reactor.stop()
if __name__ == '__main__':
pid = os.popen('ps aux | grep \[b]abysiter.py').readline().split()[1]
d = LoopingCall(testTcp).start(60)
d.addErrback(finish, pid)
reactor.run()