【发布时间】:2010-10-14 08:25:03
【问题描述】:
我有以下使用 Twisted 的 UDP 服务器:
# init the thread capability
threadable.init(1)
# set the thread pool size
reactor.suggestThreadPoolSize(32)
class BaseThreadedUDPServer(DatagramProtocol):
def datagramReceived(self, datagram, (host, port)):
#do some stuff here...
def main():
reactor.listenUDP(PORT, BaseThreadedUDPServer())
reactor.run()
if __name__ == '__main__':
main()
我希望能够对此进行守护进程,因此根据我所读到的内容,我应该使用 .tac 文件做一些事情,我可以从“twistd -y my_udp_server_file.tac”开始 - 问题是我不能查找有关如何使用这种设置执行此操作的任何文档。我能找到的只是有关如何守护简单 TCP 回显服务器的示例(即使用 .tac 文件) - 我需要一个像我拥有的那样的多线程 UDP 服务器。
任何方向将不胜感激。
【问题讨论】: