<div dir="ltr"><div><br></div>Following the code example in PEP3143 I wrote the code below. Without the daemon context I see a steady stream of writes to the output file, /tmp/xxxx but with the daemon context there is nothing. As far as I can tell I'm preserving the file object and expect to see the same stream of writes that I saw without the context.<br><br>The PEP code looks so simple and I think I've followed the pattern here but there must be something wrong with what I've written but I can't see it. Is there something more to the PEP code?<br><br>try:<br> mf = open("/tmp/xxxx", 'w+')<br>except (IOError, OSError) as e:<br> print(" ".join(["Unable to open /tmp/xxxx:",\<br> e.errno, e.strerror]))<br> exit(0)<br><br>with daemon.DaemonContext(<br> working_directory='/',<br> umask=0o002,<br> pidfile = lockfile.FileLock("/var/run/boo.pid"),<br> signal_map = {<br> signal.SIGHUP: hup,<br> signal.SIGQUIT: quit,<br> signal.SIGINT: interrupt,<br> },<br> files_preserve = [mf]<br>):<br> mf.write("Intro\n")<br> while True:<br> mf.write("1===================\n")<br> time.sleep(10)<br> mf.write("2===================\n")<br> mf.flush()<br><br clear="all"><div><div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="color:rgb(80,0,80);font-size:12.8px"><b style="font-size:12.8px"><font color="#0b5394">Bill Rees</font></b><b style="font-size:12.8px;color:rgb(136,136,136)"> </b><b style="color:rgb(136,136,136);font-family:Calibri,sans-serif"><span style="font-size:10.5pt;font-family:Arial,sans-serif">| </span></b><br style="font-size:12.8px;color:rgb(136,136,136)"><div style="font-size:12.8px;color:rgb(136,136,136)"><div style="font-size:12.8px;color:rgb(136,136,136)">Stack Labs <span style="font-family:Arial,sans-serif;font-size:small">| </span><span style="font-size:12.8px">10054</span><font size="2"> Pasadena Ave, Cupertino, CA 95014</font></div></div><div style="font-size:12.8px;color:rgb(136,136,136)"><font size="2"></font><span style="font-size:small"> </span><a href="mailto:brees@stacklighting.com" style="font-size:small" target="_blank">brees @stacklighting.com</a><span style="font-size:small"> </span></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><p style="margin:0in 0in 0.0001pt;color:rgb(34,34,34);font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:7.5pt"><font color="#999999">This electronic mail transmission may contain private, confidential and privileged information </font></span><span style="color:rgb(153,153,153);font-size:7.5pt">that is for the sole use of the intended recipient. If you are not the intended recipient, you </span><span style="color:rgb(153,153,153);font-size:7.5pt">are hereby notified that any review, dissemination, distribution, archiving, or copying of this </span><span style="font-size:7.5pt"><font color="#999999">communication is strictly prohibited. If you received this communication in error, please reply </font></span><span style="color:rgb(153,153,153);font-size:7.5pt">to this message immediately and delete the original message and the associated reply.</span></p></div></div></div></div></div></div>
</div></div></div>