On Monday, 3 April 2017 16:39:48 BST Ralph Corderoy wrote: > > I suppose that I could set up another apscheduler event to do a reboot > > at midnight. > > If they don't need to normally twiddle switches after it powers on to > have it carry out the typically desired routines, then yes you could.
Would this be a standard subprocess.call() invocation or is there a better way? > > Should I be closing it? If so, how? > > I don't remember the code precisely, but I did suggest not opening > /dev/null each time the function was called, but instead having a global > and only opening it the once. open() gives a File object and they have > a close() method. > > >>> f = open('/dev/null') > >>> f > > <open file '/dev/null', mode 'r' at 0x7f7a9e195660> > > >>> f.close() > >>> f > > <closed file '/dev/null', mode 'r' at 0x7f7a9e195660> Ahh! That's another suggestion that got forgotten along the way. Would I need to create two global instances of /dev/null if I use it twice in the same function? > Did you set `pid` to the process ID of interest? Or replace `$pid' with > that number? :-) No. I totally misunderstood the meaning of $pid. > $ python2 -c 'import time; f = open("/etc/passwd"); time.sleep(42)' & > [1] 18933 > $ ls -l /proc/18933/fd > total 0 > lrwx------ 1 ralph ralph 64 Apr 3 16:36 0 -> /dev/pts/2 > lrwx------ 1 ralph ralph 64 Apr 3 16:36 1 -> /dev/pts/2 > lrwx------ 1 ralph ralph 64 Apr 3 16:36 2 -> /dev/pts/2 > lr-x------ 1 ralph ralph 64 Apr 3 16:36 3 -> /etc/passwd > $ How would the instances of /dev/null show up? I have the same references to / dev/pts/2 plus: 1. All of the GPIO pins appear to be there. 2. /dev/urandom. 3. /dev/gpiomem. 4. anon_inode:[eventpoll11] That's it. Does that mean that my instances of /dev/null are killed when the function exits? (I reset the clock to ensure that the functions that use that feature would be run. (They are prevented from running outside Opening Hours)). Each function has been run, but of course they exit almost immediately because everything is done with subprocess.Popen(). -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2017-04-04 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR