Closed medihack closed 3 months ago
Thank you for opening the issue! This doc is quite new, it was written after the (almost) full rewrite of the Django integration.
The fact that the task has a link to the job manager is necessary to do task.defer()
but, as you mention, it's problematic in cases where the app change through time. I guess the only way to do it right is to rewrite tasks' job manager when switching app, ideally do it in a context manager and reset every task the way it was before when you're done (e.g. at the end of the test). I'll see if I can do something.
It seems that the documentation about how to test Procrastinate in Django is wrong (or outdated). For example, there is no
defer
method ofapp
(app.defer("my_task", args=(1, 2))
). I guess it should be something likeapp.configure_task("my_task", args=(1, 2)).defer()
. There is also some problem when using the in_memory_app fixture as described in the documentation. When deferring a task likein_memory_app.configure_task("example_project.example_app.tasks.example_task").defer()
the app still tries to use the DjangoConnector. So defer doesn't respect the InMemoryConnector, even when it is correctly set. The problem is that the Task uses thejob manager
of the blueprint, which is set while it is registered (so before thein_memory_app
is created). We have to figure out a way for the task to respect thecurrent_app
and itsjob_manager
or to somehow overwrite thejob_manager
(or the blueprint) of the task itself.