[Twisted-Python] tac and tap in the same file

Andrea Arcangeli andrea at cpushare.com
Sat Jan 29 09:43:39 EST 2005

While I appreciate the tweaking of the tap file for production usage,
during development it's more handy to use a tac file and avoid the
pickling that otherwise would happen too frequently for every test.

By adding these lines at the end of the tap.py file I can run both tac
and tap from the same file by using tap.py instead like if it was a tac
file (started with twistd -noy)

It wasn't obvious immediatly that it was possible.

I only had to add these lines at the end of tap.py (tap.py like in
finger example of the howto):

s = web.make_service(Options())
from twisted.application import service
application = service.Application('cpushare_web')

This takes all option defaults just fine (like if mktap was run without
tweaking parameters). I believe a cut and paste shoud work for most tap
files if they follow the same naming of the Options class.

I didn't see this trick mentioned in the docs, so JFYI.

More information about the Twisted-Python mailing list