Thanks, Jesse.
I'd managed to completely skip over this point on my first
pass through Drew's comments.
I'll implement his suggestion, with your amendment.
- dermot
On 06/04/11 00:35, Jesse Butler wrote:
On Jun 3, 2011, at 12:39 PM, Drew Fisher wrote:
usr/src/cmd/gui-install/src/gui_install_common.py
-------------------------------------------------
162: Instead of opening the file with open(), use the linecache
module:
if os.path.exists(PIDFILE):
previous_pid = int(linecache(PIDFILE, 1))
this_pid = os.getpid()
<...>
It'll save some indentation and will smartly handle errors (IOErrors,
etc.)
Quick note on this. The linecache module doesn't maintain coherency
automatically, so if it is at all possible for the contents of this file to
change after the first time it is read, you need to force it to check the
backing file and, if necessary, invalidate the cached data. This can be done
via the checkcache() method.
if os.path.exists(PIDFILE):
linecache.checkcache(PIDFILE)
previous_pid = int(linecache.getline(PIDFILE, 1))
this_pid = os.getpid()
<...>
In this case, without the checkcache() call, your previous_pid will not update
according to the file content.
Best
Jesse
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss