[Tutor] schedulers

nathan tech nathan-tech at hotmail.com
Thu Feb 28 20:59:47 EST 2019


Hopefully I am doing this right, wanted to reply to the tutor list, not 
a specific person... Anyway.

Thanks Steven and Alan for your help.

I'll look into the windows scheduler and go from there.


The code given in the original email was just an example, but none the 
less I appreciate you guys pointing out the floors. :)

Thanks again.

Nathan

On 28/02/2019 23:23, Alan Gauld via Tutor wrote:
> On 28/02/2019 14:45, nathan tech wrote:
>
>> but I'm thinking, should I do this?
> No. fOr several reasons...
>
>> def do_backup
>>    # backup code here,
>> def scheduler():
>>    global tus # tus=time until schedule
>>
>>    while(time.time()>tus):
>>     time.sleep(5)
>>    scheduler()
> scheduler doesn't actually do anything except
> spin waiting for the time up. But you know the
> current time and the due time so you can just
> sleep until the due time, no need for the loop.
>
> Also you exit the loop and then call scheduler
> again - that will immediately exit the loop
> and call scheduler again which will repeat
> "forever". I suspect you meant to call do_backup?
>
> However, if you really want to delay execution
> of do_backup you can probably do it via the OS
> Nearly every OS has a means of scheduling tasks.
> So, by splitting your app into two parts - one
> to create the scheduled task and the
> other to actually do the backup.
>
> That way the OS does all the heavy lifting,
> including restoring the schedule after an OS
> restart etc. And you only have the relatively
> easy task of telling the os to schedule a task
> and writing the backup function.
>
>> This is a program for windows.
> OK, I cant recall the Windows schedule
> program - I think it was "at" or somesuch?
>
> Then again you could just use the native Windows
> backup program which doe it all for you...
>
>


More information about the Tutor mailing list