[Tutor] Running Python Scripts at same time

Alan Gauld alan.gauld at yahoo.co.uk
Fri Jun 26 10:38:22 EDT 2020


On 26/06/2020 11:21, John Weller wrote:
> I have a Python program which will be running 24/7 (I hope 😊).  > It is generating data in a file which I want to clean up overnight.
> The way I am looking at doing it is to run a separate program 
> as a Cron job at midnight – will that work? 

Yes, there is no limit to how many concurrent python sessions you
run.(Apart from the capacity of your computer of courses)

But it will be a completely separate program. It will have no
access to the variables or state of your original program.
You won't for example be able to tell whether the original
program is writing to the file at the time you want to
delete it. You will need to ensure that the code of each
is robust enough to handle that.

The usual way of dealing with that is to get the first program
to write to a file whose name incorporates the date. Then it
will automatically create a new file each day. Your second
program can then do what it wishes with the previous days
file, certain that the first won't be interfering with it.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list