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

Compatibility with django-celery-beat

Open dgilge opened this issue 5 years ago • 1 comments

I have installed both, django-uwsgi and django-celery-beat, but they cause a bug when I want to change periodic tasks in the admin panel: http://localhost:8001/admin/django_celery_beat/periodictask/1/change/

I disabled django-uwsgi for now but I'd be happy to use it again when this is fixed. (Sorry, but I don't see a way to figure out what causes this.)

Installed:

Package Name Version
Django   2.0.13
Python   3.6.8
allauth Allauth 0.36.0.final.0
cachalot Cachalot 2.1.0
crispy_forms Crispy_Forms 1.7.2
debug_toolbar Debug Toolbar 2.0
django_celery_beat Periodic Tasks 1.5.0
django_extensions Django_Extensions 2.1.9
django_filters Django_Filters 2.1.0
django_uwsgi uWSGI for Django 0.2.2
drf_yasg Drf_Yasg 1.16.0
guardian Guardian 2.0.0
imagekit Imagekit 4.0.2
rest_framework Django REST framework 3.9.4
simple_history Simple_History 2.7.2
celery==4.3.0
kombu==4.6.3

Traceback:

KeyError: '_modules'
  File "kombu/utils/objects.py", line 42, in __get__
    return obj.__dict__[self.__name__]

Exception: you have to enable the uWSGI spooler to use @_spool decorator
  File "django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/contrib/admin/options.py", line 575, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/sites.py", line 223, in inner
    return view(request, *args, **kwargs)
  File "django/contrib/admin/options.py", line 1557, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "django/utils/decorators.py", line 62, in _wrapper
    return bound_func(*args, **kwargs)
  File "django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/utils/decorators.py", line 58, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "django/contrib/admin/options.py", line 1451, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "django/contrib/admin/options.py", line 1508, in _changeform_view
    form = ModelForm(instance=obj)
  File "django/forms/models.py", line 301, in __init__
    label_suffix, empty_permitted, use_required_attribute=use_required_attribute,
  File "django/forms/forms.py", line 95, in __init__
    self.fields = copy.deepcopy(self.base_fields)
  File "python3.6/copy.py", line 180, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "python3.6/copy.py", line 306, in _reconstruct
    value = deepcopy(value, memo)
  File "python3.6/copy.py", line 161, in deepcopy
    y = copier(memo)
  File "django/forms/fields.py", line 761, in __deepcopy__
    result = super().__deepcopy__(memo)
  File "django/forms/fields.py", line 203, in __deepcopy__
    result.widget = copy.deepcopy(self.widget, memo)
  File "python3.6/copy.py", line 161, in deepcopy
    y = copier(memo)
  File "django/forms/widgets.py", line 563, in __deepcopy__
    obj.choices = copy.copy(self.choices)
  File "django_celery_beat/admin.py", line 44, in choices
    self._choices = self.tasks_as_choices()
  File "django_celery_beat/admin.py", line 36, in tasks_as_choices
    _ = self._modules  # noqa
  File "kombu/utils/objects.py", line 44, in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
  File "django_celery_beat/admin.py", line 55, in _modules
    self.celery_app.loader.import_default_modules()
  File "celery/loaders/base.py", line 108, in import_default_modules
    raise response
  File "celery/utils/dispatch/signal.py", line 288, in send
    response = receiver(signal=self, sender=sender, **named)
  File "vine/promises.py", line 170, in __call__
    return self.throw()
  File "vine/promises.py", line 167, in __call__
    retval = fun(*final_args, **final_kwargs)
  File "celery/app/base.py", line 680, in _autodiscover_tasks
    return self._autodiscover_tasks_from_fixups(related_name)
  File "celery/app/base.py", line 693, in _autodiscover_tasks_from_fixups
    ], related_name=related_name)
  File "celery/app/base.py", line 685, in _autodiscover_tasks_from_names
    packages() if callable(packages) else packages, related_name,
  File "celery/loaders/base.py", line 224, in autodiscover_tasks
    related_name) if mod)
  File "celery/loaders/base.py", line 249, in autodiscover_tasks
    return [find_related_module(pkg, related_name) for pkg in packages]
  File "celery/loaders/base.py", line 249, in <listcomp>
    return [find_related_module(pkg, related_name) for pkg in packages]
  File "celery/loaders/base.py", line 268, in find_related_module
    return importlib.import_module('{0}.{1}'.format(package, related_name))
  File "importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "django_uwsgi/tasks.py", line 13, in <module>
    @spool
  File "django_uwsgi/decorators.py", line 165, in spool
    return spool_decorate(f, pass_arguments, _spool)
  File "django_uwsgi/decorators.py", line 157, in spool_decorate
    return _class(f, pass_arguments)
  File "django_uwsgi/decorators.py", line 131, in __init__
    "you have to enable the uWSGI spooler to use @%s decorator" % self.__class__.__name__)

dgilge avatar Jul 03 '19 22:07 dgilge

Hello @dgilge!

Exception: you have to enable the uWSGI spooler to use @_spool decorator

As I can see, you not enabled spooler in uwsgi config.

MechanisM avatar Aug 06 '19 15:08 MechanisM