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

Vincent Bernat bernat at luffy.cx
Tue Oct 14 23:53:22 EDT 2008


OoO  En cette nuit  nuageuse du  mercredi 15  octobre 2008,  vers 00:10,
"Alec Matusis" <matusis at yahoo.com> disait :

> I am not sure still how to do it:
> When I run 

> twistd --python=serv.py --logfile=serv.log

> anything  that I  put in  serv.py is  executed after  the  process has
> already been  daemonized: even if I  print or sys.stdout  on the first
> line in serv.py file, the output never goes into stdout.

You need to save sys.stdout in  serv.py and use this saved value. I have
not tested it, but maybe you need to get the file descriptor instead and
reopen it (fd=sys.stdout.fileno() and os.fdopen(fd, 'w')).
-- 
Make sure input cannot violate the limits of the program.
            - The Elements of Programming Style (Kernighan & Plauger)




More information about the Twisted-Python mailing list