django-q2 icon indicating copy to clipboard operation
django-q2 copied to clipboard

Schedule is not working

Open dev12345601 opened this issue 1 year ago • 9 comments

Schedule below is not executed. it is display on schedule but not display on failed or successful task.

schedule('math.hypot', 3, 4, schedule_type=Schedule.MINUTES, minutes=5, repeats=24, next_run=datetime.utcnow().replace(hour=18, minute=0))

How to know schedule execute ? it is failed or success ?

Screen Shot 2024-08-21 at 10 24 27 AM

dev12345601 avatar Aug 21 '24 03:08 dev12345601

Are you running python manage.py qcluster?

GDay avatar Aug 21 '24 14:08 GDay

python manage.py qcluster

Error run command above

ile "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/redis/client.py", line 898, in execute_command conn = self.connection or pool.get_connection(command_name, **options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/redis/connection.py", line 1192, in get_connection connection.connect() File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/redis/connection.py", line 563, in connect raise ConnectionError(self._error_message(e)) redis.exceptions.ConnectionError: Error 61 connecting to 127.0.0.1:6379. Connection refused.

dev12345601 avatar Aug 22 '24 01:08 dev12345601

That simply means that you don't have a broker running on 127.0.0.1:6379. You should have something running or use the django database as a broker.

GDay avatar Aug 22 '24 14:08 GDay

That simply means that you don't have a broker running on 127.0.0.1:6379. You should have something running or use the django database as a broker.

can create schedule without Q_CLUSTER configuration?

Q_CLUSTER = {
    'name': 'myproject',
    'workers': 8,
    'recycle': 500,
    'timeout': 60,
    'compress': True,
    'save_limit': 250,
    'queue_limit': 500,
    'cpu_affinity': 1,
    'label': 'Django Q2',
    'redis': {
        'host': '127.0.0.1',
        'port': 6379,
        'db': 0, },
    'ALT_CLUSTERS': {
        'long': {
            'timeout': 3000,
            'retry': 3600,
            'max_attempts': 2,
        },
        'short': {
            'timeout': 10,
            'max_attempts': 1,
        },
    }
}

dev12345601 avatar Aug 23 '24 01:08 dev12345601

can create schedule without Q_CLUSTER configuration?

Yes, but it won't run if you don't run python manage.py qcluster.

Are you locally running redis on port 6379? If not, try this:

Q_CLUSTER = {
    'name': 'myproject',
    'workers': 8,
    'recycle': 500,
    'timeout': 60,
    'compress': True,
    'save_limit': 250,
    'queue_limit': 500,
    'cpu_affinity': 1,
    'label': 'Django Q2',
    'orm': 'default',
    'ALT_CLUSTERS': {
        'long': {
            'timeout': 3000,
            'retry': 3600,
            'max_attempts': 2,
        },
        'short': {
            'timeout': 10,
            'max_attempts': 1,
        },
    }
}

That will use the database instead of redis.

GDay avatar Aug 23 '24 15:08 GDay

python manage.py qcluster

error below:

01:32:24 [Q] INFO Process-f3dbb479ea454cbaa52f0b75e661646c ready for work at 1181
01:32:24 [Q] INFO Process-cd5a42670f6143189c380068fb87cb50 ready for work at 1185
01:32:24 [Q] INFO Process-1a0850b8c0ae4624be6e6f4210ded39d ready for work at 1183
01:32:24 [Q] INFO Process-c3403265246a4436adbfa40c295d02b8 ready for work at 1184
01:32:24 [Q] INFO Process-07cb935c23e34b81b562fa69dc7020f0 monitoring at 1187
01:32:24 [Q] INFO Process-0ea827d3d4af4f698bc34f552ee154b2 ready for work at 1186
01:32:24 [Q] INFO Process-da649cd646804ba58cd6b6e39351188e pushing tasks at 1188
01:32:53 [Q] INFO Enqueued [myproject] 1
01:32:53 [Q] INFO Process-433e811386ad4456b3dcbed16bb30fd3 created task harry-apart-quiet-undress from schedule [67]
01:32:53 [Q] INFO Enqueued [myproject] 2
01:32:53 [Q] INFO Process-433e811386ad4456b3dcbed16bb30fd3 created task cup-robin-beryllium-wyoming from schedule [68]
01:32:53 [Q] INFO Enqueued [myproject] 3
01:32:53 [Q] INFO Process-433e811386ad4456b3dcbed16bb30fd3 created task autumn-bravo-twenty-mars from schedule [69]
01:32:53 [Q] ERROR Could not create task from schedule
Traceback (most recent call last):
  File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django_q/scheduler.py", line 80, in scheduler
    next_run = s.calculate_next_run(next_run)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django_q/models.py", line 266, in calculate_next_run
    next_run += add
                ^^^
UnboundLocalError: cannot access local variable 'add' where it is not associated with a value

dev12345601 avatar Aug 26 '24 01:08 dev12345601

python manage.py qcluster

error below:

01:32:24 [Q] INFO Process-f3dbb479ea454cbaa52f0b75e661646c ready for work at 1181
01:32:24 [Q] INFO Process-cd5a42670f6143189c380068fb87cb50 ready for work at 1185
01:32:24 [Q] INFO Process-1a0850b8c0ae4624be6e6f4210ded39d ready for work at 1183
01:32:24 [Q] INFO Process-c3403265246a4436adbfa40c295d02b8 ready for work at 1184
01:32:24 [Q] INFO Process-07cb935c23e34b81b562fa69dc7020f0 monitoring at 1187
01:32:24 [Q] INFO Process-0ea827d3d4af4f698bc34f552ee154b2 ready for work at 1186
01:32:24 [Q] INFO Process-da649cd646804ba58cd6b6e39351188e pushing tasks at 1188
01:32:53 [Q] INFO Enqueued [myproject] 1
01:32:53 [Q] INFO Process-433e811386ad4456b3dcbed16bb30fd3 created task harry-apart-quiet-undress from schedule [67]
01:32:53 [Q] INFO Enqueued [myproject] 2
01:32:53 [Q] INFO Process-433e811386ad4456b3dcbed16bb30fd3 created task cup-robin-beryllium-wyoming from schedule [68]
01:32:53 [Q] INFO Enqueued [myproject] 3
01:32:53 [Q] INFO Process-433e811386ad4456b3dcbed16bb30fd3 created task autumn-bravo-twenty-mars from schedule [69]
01:32:53 [Q] ERROR Could not create task from schedule
Traceback (most recent call last):
  File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django_q/scheduler.py", line 80, in scheduler
    next_run = s.calculate_next_run(next_run)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django_q/models.py", line 266, in calculate_next_run
    next_run += add
                ^^^
UnboundLocalError: cannot access local variable 'add' where it is not associated with a value

any comment on this ?

dev12345601 avatar Aug 27 '24 09:08 dev12345601

Try to remove your existing schedule and add a new one through admin. It looks like the schedule type is not recognized for some reason. Never seen this before.

GDay avatar Aug 27 '24 13:08 GDay

Try to remove your existing schedule and add a new one through admin. It looks like the schedule type is not recognized for some reason. Never seen this before.

01:37:28 [Q] INFO Process-1b0f3e8a9c5a4895baa3fc37c7fa6609 ready for work at 5337 01:37:28 [Q] INFO Process-21d6d57b2d8b48f3a8587eb436694e97 ready for work at 5339 01:37:28 [Q] INFO Process-7831525393d044adbb6a7d24e02e0ee4 monitoring at 5342 01:37:28 [Q] INFO Process-57a27f76b0b94b5f8cba7a528bdb8043 ready for work at 5341 01:37:28 [Q] INFO Process-ef56640d20dd41b0a3543e2ffee45f86 ready for work at 5340 01:37:57 [Q] ERROR Could not create task from schedule Traceback (most recent call last): File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django_q/scheduler.py", line 80, in scheduler next_run = s.calculate_next_run(next_run) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django_q/models.py", line 266, in calculate_next_run next_run += add ^^^ UnboundLocalError: cannot access local variable 'add' where it is not associated with a value

dev12345601 avatar Aug 28 '24 01:08 dev12345601