Forums

Always-on tasks - Problem

Hi!

Today, unexpectedly, my task status changed to "Starting" and this started appearing in the logs.

2026-08-17 21:09:17 - Task preparing to start

Aug 17 21:11:10 [2026-08-17 21:11:10] Another task instance is already running

I only have one "Always-on" task, and no other tasks or anything on the console page. It was working normally, but this happened today after a few hours. I tried deleting and recreating it, but the same thing keeps happening.

Fix for me please.

This print statement is appearing because I had implemented a task_lock to prevent the same code from running twice. I ended up removing the task_lock from the code, and now it works. The lock was intended to prevent the same PID from executing the task's .py file twice—essentially to avoid duplicate execution.

Example:

def acquire_task_lock():
    lock_file = open(TASK_LOCK_PATH, "a+", encoding="utf-8")
    try:
        fcntl.flock(
            lock_file.fileno(),
            fcntl.LOCK_EX | fcntl.LOCK_NB
        )
    except BlockingIOError:
        lock_file.close()
        return None

task_lock = acquire_task_lock()

if task_lock is None:
    print("Another task instance is already running")
    return

I removed it, and it seems to be working again.

Resolved. You can close this topic.

Thanks for letting us know.