<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Sep 20, 2007, at 7:46 PM, Arvind Singh wrote:</DIV><BLOCKQUOTE type="cite"><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Monaco; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><DIV link="blue" vlink="purple" lang="EN-GB"><DIV><P><SPAN style="font-size: 10pt;; font-size: 13.3333px; "><SPAN class="Apple-style-span" style="font-size: 13.3333px; ">file('/var/lock/Application.lock', 'w').write(str(os.getpid()))</SPAN></SPAN></P><P><SPAN style="font-size: 10pt;; font-size: 13.3333px; "><SPAN class="Apple-style-span" style="font-size: 13.3333px; "> </SPAN></SPAN>Which to be honest appears to run just fine, when I look in that file it always contains the correct process ID, for instance, 3419 or something like that.</P></DIV></DIV></BLOCKQUOTE><DIV>I honestly doubt that. The I/O is buffered and you need to flush()/close() the file. Otherwise data may not get written until python interpreter exits.</DIV></DIV></SPAN></BLOCKQUOTE></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Monaco; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; ">Isn't the file closed after the file().write()?  Seems to me that the great garbage collector in the sky will happily flush(), close() and forget it ever happened...  </SPAN></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Monaco; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; ">-Michael<BR class="Apple-interchange-newline"><DIV style="text-align: justify;; font-family: Helvetica; font-size: 12px; "><BR class="khtml-block-placeholder"></DIV><DIV style="text-align: justify;; font-family: Helvetica; font-size: 12px; "><SPAN class="Apple-style-span" style="font-family: Helvetica; font-size: 12px; text-align: justify; ">---</SPAN></DIV><DIV style="text-align: justify;; font-family: Helvetica; font-size: 12px; "><SPAN class="Apple-style-span" style="font-family: Helvetica; font-size: 12px; text-align: justify; ">"Those who don't understand UNIX are condemned to reinvent it, poorly."  --Henry Spencer</SPAN></DIV><DIV style="font-family: Helvetica; font-size: 12px; "><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></BODY></HTML>