[Twisted-Python] How to make twistd print to stdout

Alec Matusis matusis at yahoo.com
Mon Oct 13 22:49:01 EDT 2008

I have an application that is start from a command line by a shell script
that has this:

/usr/local/bin/twistd --no_save --reactor=epoll --pidfile=logs/serv.pid
--logfile=logs/serv.log --python=serv.py


application =

my_service = service.MyService()


In MyService class I have:

def startService(self):
	if bad_config_file:
		#I want to print to stdout here end quit immediately??

I cannot force twistd to print to stdout after that comment line, probably
because it's daemonized by then. 
print 'bad error' writes it to --logfile=logs/serv.log
I tried sys.stdout/stderr.write('bad error') - it's not written anywhere,
not even to the logfile.
sys.exit('bad error') exits, but does not print anywhere either.

How do I make it print to stdout?

More information about the Twisted-Python mailing list