IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    python twisted 程序hello world

    istrone发表于 2016-07-25 13:32:25
    love 0
    
    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:
    服务器端js node.js Hello world
    一起学Yii----1.Hello world
    一段多线程死锁代码
    ubuntu下搭建j2me环境和j2me版本hello world
    ubuntu gtk 配置与hello world
    无觅


沪ICP备19023445号-2号
友情链接