django-celery-monitor icon indicating copy to clipboard operation
django-celery-monitor copied to clipboard

Celery Monitor no longer works with Django 2.2

Open AndrewModus opened this issue 5 years ago • 8 comments

Celery Monitor no longer works with Django 2.2:

More specifically:

[2019-04-05 10:05:57,937: ERROR/MainProcess] Error in timer: TypeError('get() argument after ** must be a mapping, not str')
Traceback (most recent call last):
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/kombu/asynchronous/timer.py", line 166, in apply_entry
    entry()
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/kombu/asynchronous/timer.py", line 68, in __call__
    return self.fun(*self.args, **self.kwargs)
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/kombu/asynchronous/timer.py", line 127, in _reschedules
    return fun(*args, **kwargs)
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/celery/events/snapshot.py", line 72, in capture
    self.state.freeze_while(self.shutter, clear_after=self.clear_after)
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/celery/events/state.py", line 456, in freeze_while
    return fun(*args, **kwargs)
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/celery/events/snapshot.py", line 69, in shutter
    self.on_shutter(self.state)
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/django_celery_monitor/camera.py", line 125, in on_shutter
    self.handle_worker(worker)
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/django_celery_monitor/camera.py", line 77, in handle_worker
    update_freq=self.worker_update_freq,
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/django_celery_monitor/managers.py", line 62, in update_heartbeat
    defaults={'last_heartbeat': heartbeat},
  File "/Users/andrewjones/.virtualenvs/dpet-janitor/lib/python3.7/site-packages/django_celery_monitor/managers.py", line 33, in select_for_update_or_create
    obj = self.select_for_update().get(**lookup)
TypeError: get() argument after ** must be a mapping, not str

It looks like it's an issue where the django internal method _extract_model_params is no longer returning (lookup, params) but only params

Link to the django source code (search for def _extract_model_params): https://docs.djangoproject.com/en/2.1/_modules/django/db/models/query/ https://docs.djangoproject.com/en/2.2/_modules/django/db/models/query/

AndrewModus avatar Apr 05 '19 10:04 AndrewModus

I am having the same issue now. Any updates on this?

cryocaustik avatar May 02 '19 05:05 cryocaustik

Me too, I have looked quickly at the problem and it seems that select_for_update_or_create is an extension of select_for_update added to the base object manager. We have to rewrite this fonction ! I don't have time to check this now but if no one do, I will try later this month.

stygmate avatar May 02 '19 07:05 stygmate

Has anyone found a workaround for this yet? Really want to use this and ditch flower.

NerdSec avatar Jul 17 '19 12:07 NerdSec

@AndrewModus @NerdSec @cryocaustik @stygmate

Quick fix...

Go to file django_celery_monitor/managers.py and the function select_for_update_or_create should look like the following:

class ExtendedQuerySet(models.QuerySet):

    def select_for_update_or_create(self, defaults=None, **kwargs):
        return self.update_or_create(defaults, **kwargs)

https://github.com/SYNchroACK/django-celery-monitor/blob/master/django_celery_monitor/managers.py#L17

SYNchroACK avatar Aug 22 '19 14:08 SYNchroACK

Seems like the repo is abandoned. @SYNchroACK Why not package & publish using pip? Or if @jezdez could transfer the ownership to someone for this project?

NerdSec avatar Nov 13 '19 06:11 NerdSec

I would really love if one of the PRs would merge :( I want to use this project too.

killswitch-GUI avatar Apr 30 '20 18:04 killswitch-GUI

This is still an issue, any chance of getting a new release out?

fericsepi avatar Jun 03 '20 01:06 fericsepi

Adding my voice to the chorus.

siovene avatar Apr 10 '23 19:04 siovene