[Twisted-Python] Daemonizing app (two udp servers + flask)

Beth beth.null at gmail.com
Tue Jul 2 13:02:03 MDT 2013


Hi there!

Can someone give me a hand in how to daemonize one application?

My application has two udp servers that subclass from DatagramProtocol and
are launched via reactor.listenUDP.

I think that the way to go is twistd, however some doubts come to me as
flask is involved and even I don't know if this is the proper place to ask
(maybe the flask support list?)

My current implementation goes like this:

class Server(DatagramProtocol):

def datagramReceived(self, data, (host, port)):

....

sever = Server()

reactor.listenUDP(port, server)

....

To deploy the app, in the application framework doc is said that you can
create a .tac file for using with twistd. In this tac file I think that I
need to wrap my "DatagramProtocol" into a Factory, then within a Service
and link that service to the application. No problem on that (I think)

However, I'm also using flask for exposing a basic restful api. And I have
no idea in how I can wrap it into a factory/service/application.

In my code flask is tied to the reactor in the following way:

flask_app = Flask(__name__, static_folder="www", static_url_path="")

flask_resource = WSGIResource(reactor, reactor.getThreadPool(), flask_app)

flask_site = Site(flask_resource)

reactor.listenTCP(8080, flask_site)

--------

In the flask website it's said that you can run a flask application using a
standalone wsgi container like the default twisted one with:

twistd web --wsgi myproject.app

However I think that it has nothing to do with my problem.

I'm not a twisted expert however I've been using it from the past six
months, but running it under Eclipse and directly under the console,
however now is time to deploy and I'm really confused with all this
Application, Service, MultiService, Factory, Protocol and such stuff.
listenTCP and listenUDP seemed so easy!!! ;)

At this point I'm in a dead end trying to run the app at startup, any
suggestion?, other alternative to twistd?

Thanks in advance, best regards, Beth.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20130702/f3fe08f4/attachment.html>


More information about the Twisted-Python mailing list