我不知道如何在twisted.internet.ClientFactory
中使用twisted.internet.loopingCall()
之类的东西
我需要编写python脚本来扫描目录中有电话号码的传入文件,读取它们,并使用使用twisted
库的YATEyaypm
python模块进行调用。在
client_factory = yaypm.TCPDispatcherFactory(start_client)
reactor.connectTCP(host, port, client_factory)
reactor.run()
其中yaypm.TCPDispatcherFactory
派生自twisted.internet.ClientFactory
和{
如果start_client
只进行演示调用:
一切都好。在
(dialer
是实现yaypm.flow
逻辑的对象,完整描述放在http://docs.yate.ro/wiki/YAYPM:Bridge_and_then_unbridge中)
我需要在start_client
中写这样的东西
d = dialer(client_yate)
files = os.listdir(input_directory)
for filename in files:
<read caller and target numbers from file>
d.call(caller, target)
time.sleep(interval)
我知道在主线程中使用sleep函数会导致死锁。 我应该如何实现上面的算法?在
如果与} 的行为类似于
inlineCallbacks
修饰符一起使用,^{sleep()
调用。下面是一个使用ClientFactory
的简化示例:上面的代码本质上就是库对传入的回调所做的操作。如您所见,对
repeat_forever('running')
的调用与客户端连接后调用的调用同时运行。在相关问题 更多 >
编程相关推荐