closeio / closeio/tasktiger

Periodic tasks not working

Open
#91 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
95
Avg merge
4d 21h
Merged PRs (30d)
1

Description

I can't seem to get the periodic tasks to execute, or show up in the 'scheduled' queue.

Using the following tasks.py for debug:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import redis
from tasktiger import TaskTiger
from tasktiger.schedule import periodic

tiger = TaskTiger()


@tiger.task(schedule=periodic(seconds=1), queue='periodic')
def periodic_task():
    """Periodic task."""
    conn = redis.Redis(decode_responses=True)
    conn.incr('period_count', 1)


@tiger.task()
def test_task():
    """Minimal task."""
    print('Hello')

Running tasktiger as shown in docs:

$ PYTHONPATH=. tasktiger

I can run the minimal test_task:

>>> import tasks
>>> tasks.test_task.delay()
<Task <function test_task at 0x7f03aaacfd08>>

I see the output in the log, but there is no evidence of the periodic_task and the redis key 'period_count' never increments:

{"pid": 27295, "queues": [], "exclude_queues": [], "single_worker_queues": [], "event": "ready", "level": "info", "timestamp": "2017-10-26T12:43:35.236665Z"}
{"pid": 27295, "queue": "default", "event": "new queue", "level": "debug", "timestamp": "2017-10-26T12:44:09.818470Z"}
{"pid": 27295, "queue": "default", "src_queue": "queued", "dest_queue": "active", "qty": 1, "event": "moved tasks", "level": "debug", "timestamp": "2017-10-26T12:44:09.819402Z"}
{"pid": 27295, "queue": "default", "child_pid": 27318, "func": "tasks:test_task", "task_id": "c44b198caac44250d06fc5dfc3249960d9eb5bfbe76d8bb848ddb419c8382323", "params": {"args": [], "kwargs": {}}, "event": "processing", "level": "info", "timestamp": "2017-10-26T12:44:09.820179Z"}
Hello
{"pid": 27295, "queue": "default", "attempted": 1, "processed": 1, "event": "processed", "level": "debug", "timestamp": "2017-10-26T12:44:09.823499Z"}
{"pid": 27295, "queue": "default", "task_id": "c44b198caac44250d06fc5dfc3249960d9eb5bfbe76d8bb848ddb419c8382323", "event": "done", "level": "info", "timestamp": "2017-10-26T12:44:09.825171Z"}
{"pid": 27295, "queue": "default", "src_queue": "queued", "dest_queue": "active", "qty": 0, "event": "moved tasks", "level": "debug", "timestamp": "2017-10-26T12:44:09.825592Z"}
{"pid": 27295, "time_total": 60.00032615661621, "time_busy": 0.003787517547607422, "utilization": 0.006312494931645924, "event": "stats", "level": "info", "timestamp": "2017-10-26T12:44:35.237246Z"}

Am I missing something?

By the way, TaskTiger is a great project!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided tasks.py reproduction and the tasktiger command entry point, focusing on how schedule.periodic tasks are registered and exposed in the scheduled queue. Verify the behavior against Redis and the period_count key; the issue is resolved when periodic_task runs and the key increments as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, redis
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.