Python 扭曲的UDP服务器-daemonize?
我有以下使用Twisted的UDP服务器:Python 扭曲的UDP服务器-daemonize?,python,twisted,daemon,Python,Twisted,Daemon,我有以下使用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 so
# 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()
我希望能够将其daemonize,因此从我所读到的内容来看,我应该使用一个.tac文件来做一些事情,我可以从“twistd-y my_udp_server_file.tac”开始,问题是我找不到任何关于如何使用这种设置来执行此操作的文档。我所能找到的只是关于如何对简单的TCP echo服务器进行后台监控(即使用.tac文件)的示例—我需要一个与我现有的一样的多线程UDP服务器
任何指示都将不胜感激 twistd中的守护代码不关心您是提供UDP还是TCP服务。对UDP服务器进行后台监控的方式与对TCP服务器进行后台监控的方式相同。您应该能够以TCP echo服务器为例为UDP服务器编写.tac文件。尝试以下操作:
import twisted.application
application = twisted.application.service.Application("Scotty's UDP server")
twisted.application.internet.UDPServer(PORT, BaseThreadedUDPServer()).setServiceParent(application)
谢谢这就是我要找的。