import traceback def hello(): print 'Hello from the reactor loop!' print 'Lately I feel like I\'m stuck in a rut.' s_data = traceback.format_stack() print s_data from twisted.internet import reactor reactor.callWhenRunning(hello) print 'Starting the reactor.' reactor.run()
启动以后将执行hello 函数,其中reactor 为单例模式,可以在任何地方引用,均获得同一个实例对象。
错误出现的时候,可以用 traceback.format_stack() 获取出错的栈信息.
Maybe you like these: |
![]() |
![]() |
![]() |
![]() |
![]() |
无觅 |