Skip to content

Error with deserialize JobModel #291

@gkieninger

Description

@gkieninger

Describe the bug
I get Errors in the Admin when I click on the successful Jobs or on Workers:

obModel.__init__() missing 8 required keyword-only arguments: 'name', 'created_at', 'args', 'kwargs', 'queue_name', 'description', 'func_name', and 'meta'
Request Method: GET
http://localhost:8011/scheduler/queues/default/finished/jobs
5.2.4
TypeError
JobModel.init() missing 8 required keyword-only arguments: 'name', 'created_at', 'args', 'kwargs', 'queue_name', 'description', 'func_name', and 'meta'
/venv/lib/python3.12/site-packages/scheduler/redis_models/base.py, line 111, in deserialize
scheduler.views.queue_views.list_registry_jobs
/venv/bin/python3
3.12.11
['/opt/project', '/opt/.pycharm_helpers/pydev', '/opt/.pycharm_helpers/third_party/thriftpy', '/opt/.pycharm_helpers/pydev', '/opt/project', '/opt/.pycharm_helpers/pycharm_display', '/opt/.pycharm_helpers/pydevd_asyncio', '/usr/local/lib/python312.zip', '/usr/local/lib/python3.12', '/usr/local/lib/python3.12/lib-dynload', '/venv/lib/python3.12/site-packages', '/opt/.pycharm_helpers/pycharm_matplotlib_backend', '/opt/.pycharm_helpers/pycharm_plotly_backend']

in the deserialize of the BaseModel I see that the 'data' is
{'ended_at': '2025-08-03T09:06:27.044926+00:00', 'last_heartbeat': '2025-08-03T09:06:27.044926+00:00', 'status': 'finished'}

and class should be create with the data in line 111

{'ended_at': datetime.datetime(2025, 8, 3, 9, 6, 27, 44926, tzinfo=datetime.timezone.utc), 'last_heartbeat': datetime.datetime(2025, 8, 3, 9, 6, 27, 44926, tzinfo=datetime.timezone.utc), 'status': <JobStatus.FINISHED: 'finished'>}

To Reproduce
Steps to reproduce the behavior:
I created a new project with Django 5.2, newest tasks-scheduler and Postgres(15.1) and Redis (7.0) with a docker-compose.

from django.http import HttpResponse
from scheduler import job
import time

@job()
def long_running_func():
print("start the function")
time.sleep(30)
print("function finished")

def run_job(request):
if request.method == "GET":
print("got a GET-request")
long_running_func.delay()
return HttpResponse("OK - got a GET request")
return HttpResponse(status=405)

Expected behavior
No error message

Screenshots

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS
  • python version 3.12.11
  • django version 5.2.4
  • requirements.txt?

[project]
name = "testscheduler"
version = "0.1.0"
description = "Add your description here"
requires-python = ">=3.12"
dependencies = [
"django~=5.2.4",
"django-redis>=5.4.0",
"django-tasks-scheduler~=4.0.6",
"psycopg[binary]>=3.2.6",
]

Additional context
This error occurs not always, but very often.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions