Forums

scheduled tasks

two scripts from scheduled tasks: 'emailsender.py' successfully doing 'walk_sources.py' does nothing, and waiting for something, as I can see from mysql database, in which that script stores results; when run it from console all fine... ?

I think we'll need a little more detail to try and identify a problem here. To clarify, you're saying that you have two separate scheduled tasks, one of which (emailsender.py) runs successfully to completion but the other (walk_sources.py) does not. Is that summary correct?

Do you have indications that walk_sources.py is definitely starting? It sounds from the name like it's designed to walk through a directory tree or similar - assuming I'm right, are the files it's processing in your home directory or on a Dropbox share, or both?

Without knowing more about what your script is trying to do it's really hard to guess why it might be having problems. In general, however, I would suggest that you insert code into the failing script which appends messages to a log file in your home directory, something like this:

import os
import time

def log_progress(message):
    with open(os.path.expanduser("~/walk_sources.log"), "a") as fd:
        print >>fd, time.strftime("%Y-%m-%d %H:%M:%S: ") + message

Then scatter calls to log_progress() liberally throughout your code and you can see what progress your script is making. It may be that it's getting to a particular place and getting stuck, and the log messages should indicate that. It also may be that it's just running a lot slower than you're expecting for some reason, and since the messages have timestamps on you should be able to tell that too.

As an aside, the above approach to logging is quite crude and somewhat inefficient (since it opens and closes the file for each log message), but it's simple and should be easy to insert into existing code. As a general rule, however, if you're writing code to run in an automated manner then you should plan in good logging from the start. As a starting point I suggest you check out Python's standard logging module, which is a little complicated at first but offers power and flexibility (such as a variety of logging levels, multiple logging destinations and flexible format specifiers).

Another thing is that if the contents of 'walk_sources.py' aren't confidential, it would be quite helpful if you posted them here.

+1 to both of those. @kerniexvid sometimes when a process never finishes, it can look like it never started on the scheduled tasks page (we need to fix that) -- so if you follow @Cartroo's suggestion then you're likely to find out what the problem is.

@kerniexvid: Has this worked itself out?

~a2j