Forums

old/deprecated style of long-running tasks

I've been using the "old" style of long-running tasks whereby the tasks checks for the presence of a lock before continuing. I've noticed that since the system upgrade which added the new style of long-running tasks (~oct 24), this old method is not working. The method always returns as locked, and the task does not run.

Is this a known change since the introduction of the new long-running tasks system?

def currentlyLocked(user):
global lock_socket
lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
try:
    lock_id = user+"-socket-lock"
    lock_socket.bind('\0' + lock_id)
    logging.debug("Acquired lock %r" % (lock_id,))
    return False
except socket.error:
    # Socket already locked, task must already be running
    logging.info("Failed to acquire lock %r" % (lock_id,))
    return True

No, the 2 are entirely separate. Do you have multiple tasks that may be sharing a lock accidentally? Is the task in question actually running when the task returns the lock?

Thanks Glenn. This is Interesting...I'll have to examine it in more depth, but removing that check allowed the task to run successfully. The task seemed to be hanging on that check. I'll look into it in more detail.

also perhaps try running the socket lock code from a python console to see what happens? (it actually should not see the same lock on your console, as it would be a different server, but just see if that is also hanging)

I ran the same code from a console and everything ran as expected, no lock.

I've checked for running processes on the tasks page and, at least on the tasks page, it shows that nothing is running. For now, I've just bypassed the lock check and added some auto-exit logic to ensure that the script is not running when the tasks runs.