Forums

Empty scheduled tasks

Hello guys. Why I can see empty scheduled tasks with out command and why I can't kill them all? I have tried to kill them one by one, but I've got no result. Empty scheduled tasks

That's odd. It looks like your scheduled tasks aren't exiting properly, and are being left on the system as "defunct" processes. What are you doing in the tasks?

I made sqlite.db and every hour parse data from another web site. The code is like this: connect to db; make a cursor; grab the data with requests and beautiful soup; insert data into db; close connection.

And also I have removed almost all tasks to test who make that :)

Hmm, it doesn't sound like there's anything there that should cause problems like that. I've cleared down all of the rogue processes. Can I take a look at your code? We can see it from our side, but we always ask permission first.

You can look. Check this one /DavisMerrit/journal/b3data.py, because I got errors after adding this one into schedule. Thanks for helping ^^

I have only one task at schedule tab but I still have this weird running empty tasks. Any ideas how to rid off them?

Random thought- are you always closing the connections? (eg: is it in a try/finally block, or is it possible that the code could have exited early and thus left a db connection open?)

At this moment I have only one task, which does not use db at all. It parses data and save into txt file. And I use with block to write data there.

Wait- now I'm confused. When I was looking at your post earlier I thought it was journal/b3data.py that was creating orphaned processes? I currently see a different scheduled task on there- do you know if this one is also creating new processes? Or are those just the old ones left over from journal/b3data.py?

Actually, all the orphaned tasks were started ~24hrs ago. So it doesn't seem like your current scheduled task that just parses data and saves into a txt file is the culprit.

Yeah, you are right. But at this moment I have only one task and that weird empty tasks still appear.

Wait. How are you seeing this? All of those tasks were started 24hrs ago. ie. they do not have anything to do with your script (I'm assuming it was just added less than a couple hrs ago)

As I remember, I've added that one script yesterday before I went sleep. And every time, when I check schedule tasks I see more and more empty tasks. That's why I believe the problem with any of my scripts in schedule. Btw, I use this piece of code:

def main():
    server_now = datetime.now()
    if server_now.hour % 3 != 0:
        print(server_now)
    else:
        run_the_script()

to save CPU usage. Can this be the problem?

Just dug around on your task server. I have send you an email with a count of the scheduled tasks that are still running (just in case/for privacy).

My current hypothesis is that a lot of your tasks are taking more than 7 hrs to run, and so they are actually just adding up because they are not done running yet.

And because you don't use a lock but run your tasks every hour, then you are getting more than 7+ processes per task being stacked up because the previous one isn't done running yet.

See here for how to use a lock.

And I'm thinking the weird defunct processes are due to your processes being killed after running for a super long time.

There are should not be any task running longer than 5 minutes. When I run them manually - there are just few seconds to see a result. And I've used a lock, for 2 scripts, when I needed long term run process. But they are not in scheduler anymore.

Sorry about the misdirection. I just realized that many of the process list that I compiled are defunct/dead processes that aren't being reaped (ie. what Giles said initially). Technically that's not horrible- it's not going to use up cpu time and they will just get reaped eventually. Is there anything issues that this is causing?

Nope. There is no issues. I just want a button to kill them all :D Thanks for helping.