Forums

Always-on task not starting

I have an always-on task which has been running successfully since March. Today it is stuck on 'Preparing to start' and despite refreshing it doesn't start. The log is empty and the edit and delete buttons are disabled. If I look at the running tasks it is not listed despite being in the 'Preparing to start' status. I have the feeling this is related to the recent upgrades you released. I've specified my task as follows:

workon my-virtualenv && python /home/myusername/myproject/my_script.py

What has changed that is affecting this script? Also yesterday I noticed that I was in the tarpit despite making no major changes that could affect CPU time. I also have another always-on task that is declared in the same way and it works perfectly. It is a less complext script though.

It now magically and unexplainly started working, but I really need to get of the bottom of this and understand why it happened and make sure it does not happen again. This script is vital for my project and I need it to run reliably. Could you please help in identifying the cause of this?

I've also experienced another error which may be related to this and could help in troubleshooting. I use a filelock mechanism before editing and accessing files that are used by other scripts. It has worked with no issues since last year, but yesterday night it is sometimes throws the following error:

self.fd = os.open(self.lockfile, os.O_CREAT|os.O_EXCL|os.O_RDWR)
FileExistsError: [Errno 17] File exists: '/home/myusername/myproject/static/file_name.json.lock'

and as a result of that error I get a timeout expecption:

raise FileLockException("Timeout occured.")
utility.filelock.FileLockException: Timeout occured.

The script that got stuck in the 'Preparing to start' status since midnight uses that file, but I don't understand why it didn't resume automatically.

Thanks for letting us know! It looks like your account went into the tarpit yesterday; when that happens, it is stopped and then restarted. This is all normal behaviour, but yesterday it happened while we were having larger system issues, and the "restart" message got dropped, so when everything else recovered, your task was not started up again. We've manually restarted it, and it's running fine now.

Thanks @giles. Is it possible to get a System Issue notification maybe by email when you are having issues so I can keep an eye on my tasks?

We can't send out emails for unscheduled downtime, unfortunately (sending them to everyone would take so long that the outage would well be over before you receive it) but if you follow us on Twitter you'll see posts when we're having any system issues.

Cool! I will follow you on Twitter then.

hi, i have been getting the same thing here too > continuous task not logging results , stuck on Task preparing to start..

I am not getting logs , but my continuous task appears to be running.. Can you check my current continous task?

"Task preparing to start" usually means that your script is exiting and we try to run it again but with longer intervals between runs.

exiting, meaning it is already exited the loop and finished?

Sorry, I think @fjl misunderstood what you were asking about. Is the "Task preparing to start" in the task logs? If you're not seeing expected logging in the always-on task logs, it might be being buffered. See the "Stuff that you print doesn't appear in the log" section in the debugging section of the Always-on tasks help page.