Forums

Schedule a task which should be run after every 2 min

Hi, Is it possible to schedule a task which will run after every 2 min if yes then how much CPU usage it will take?

the amt of cpu depends on the particular task

(eg: some tasks may run for a long wall time but take very little cpu cycles)

what is the use case for this task?

Hi Conrad,

The task is to fetch the details of the ship from the server. It will take min 1 sec and max 10 sec for complete execution. As the process waits for 10 sec for the response from the server.

And there is no option in the scheduler of every 2 minutes.

anyone for reply?

check out these tips for running async tasks: https://help.pythonanywhere.com/pages/AsyncInWebApps/

thanx for the response but that wouldn't work for me as the request queue on the server got emptied after every 10 minutes that means i need to fetch the queue within 10 minutes otherwise i will lost the position of the vessel for that 10 minute quarter. Is there any other suggested solution for this ? Can't run this request detail on user call.

wouldn't a while True loop running permanently be able to fetch your queue almost immediately? maybe have another read of the linked help page, and the "long-running-tasks" page that's linked from there?

Hmmm.. I have a web-page scraper running in console to temporarily (1) capture data from a remote system until I get the "real" event driven stuff working (see my post on XML conversion).

So, I have noticed no rhyme or reason to my console task getting killed. Sometimes it runs for days. Some days it gets killed every few hours. Sometimes it gets killed a few minutes after I re-start it. Such fun!

Sadly, I think relying upon a "pull" or "polling" system for mission critical data input is a bad idea. Until/unless PAW can support something like Linux systemd that can auto restart a daemon on reboot or when it crashes.

1: temporary for the last 1-2 months and counting...

Regards,

Rich.

consoles do get restarted now and again. please read the tips here for how to run a daemon/ async system: : https://help.pythonanywhere.com/pages/AsyncInWebApps/

thanx harry. i will try

HI, I tried the solution with assigning a unique lock to each task. It goes fine but inspite of looking out the file modification date is there any other method to see whether the process is running or not?

on the schedule tab you can click the "fetch process list" button?