【问题标题】:Run autobahn application with twistd使用 twistd 运行高速公路应用程序
【发布时间】:2012-05-04 14:57:12
【问题描述】:

我在 Twisted 上使用 autobahn lib 开发了一个 websocket 服务器。现在我想用 twistd 将它作为守护进程运行。如果是简单的 TCP 服务器,我会这样做:

application = service.Application("someapp")  # create the Application
someService = internet.TCPServer(port, someFactory) # create the service
someService.setServiceParent(application)

在该示例中,我使用的是 TCPServer 类而不是 reactor.listenTCP 函数。

在高速公路 api 参考中,我只发现了 listenWS 函数(例如用于 TCP 服务器的 listenTCP),而没有关于 WSServer 类。

所以我的问题是如何让我的应用程序与 twistd 一起工作?也许我应该实现自己的服务 WSServer 类来扩展扭曲的服务类?

【问题讨论】:

    标签: python twisted twistd autobahn


    【解决方案1】:

    是的。创建自己的服务。在其startService 方法中调用listenWS。在stopService方法中调用shutdown方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-09
      相关资源
      最近更新 更多