title: Celery/Redis infinite loading
body: <p>Thanks in advance, i'm trying to get a litlle bit familliar with celery bit I can't solve my problem, it's been 4 hours i'm trying to figure what's wrong but I can't tell. Everything was working fine this morning but now i'm facing an infinite loading while submitting a form.</p>
  <p>first of all I'm on arch and using last version of each package, here's my code and messages i get from the terminal :</p>
  <p><strong>configuration :</strong></p>
  <p>demo/settings/base.py :</p>
  <pre><code>INSTALLED_APPS = [
  'users.apps.UsersConfig',
  'django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'core',
  'books',
  'django_celery_results',]
  
   CELERY_RESULT_BACKEND = 'django-db'
   CELERY_BROKER_URL = f'redis://{config(&quot;REDIS_HOST&quot;)}:{config(&quot;REDIS_PORT&quot;)}/{config(&quot;REDIS_CELERY_DB&quot;)}'
  
  DATABASES = {
  'default': {
      'ENGINE': 'django.db.backends.sqlite3',
      'NAME': os.path.join(BASE_DIR, 'db_celery__.sqlite3'),
  }
  }
  </code></pre>
  <p>.env :</p>
  <pre><code>REDIS_HOST=localhost
  REDIS_PORT=6379
  REDIS_CELERY_DB=0
  </code></pre>
  <p><strong>my models</strong> books/models :</p>
  <pre><code>from django.db import models
  from PIL import Image
  from django import forms
  from demo import tasks
  
  
  def resize_model(booquin):
      img = Image.open(bouquin.cover.path)
  
      if img.height &gt; 300 or img.width &gt; 300:
          output_size = (300, 300)
          img.thumbnail(output_size)
          img.save(bouquin.cover.path)
          bouquin.save()
  
  
  class Bouquin(models.Model):
      titre = models.CharField(max_length=200)
      cover = models.ImageField(upload_to=&quot;cover&quot;)
  
  def __str__(self):
      return self.titre
  
  
   class Bouquin_Form(forms.ModelForm):
      def save(self, commit=True):
          book = super().save(commit)
          tasks.resize_book_celery.apply_async((book.id,))
          return book
  
       class Meta:
         model = Bouquin
         fields = [&quot;titre&quot;, &quot;cover&quot;]
  </code></pre>
  <p>my demo/tasks.py ( I'm mixing up models andf forms in the same file cause it's just for testing purpose)</p>
  <pre><code>from celery import shared_task
  from books import models
  
  
  @shared_task
  def resize_book_celery(book_id: int):
      models.resize_model(models.Bouquin.objects.get(id=book_id))
  </code></pre>
  <p>my demo/celery.py:</p>
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings.base')
  
  app = Celery('demo')
  
  app.config_from_object('django.conf:settings', namespace='CELERY')
  
  app.autodiscover_tasks()
  </code></pre>
  <p>and finally my view : books/views.py</p>
  <pre><code>from django.shortcuts import render, reverse, redirect
  from .models import Bouquin, Bouquin_Form
  from django.contrib import messages
  
  
  def create_book(request):
      book_listing = Bouquin.objects.all()
  
      if request.method == 'POST':
          form = Bouquin_Form(request.POST, request.FILES)
          if form.is_valid():
              form.save()
              return redirect(&quot;create-book&quot;)
  
      else:
          form = Bouquin_Form()
  
      context = {&quot;book_listing&quot;: book_listing, &quot;form&quot;: form}
  
      return render(request, &quot;demo/book_listing.html&quot;, context)
  </code></pre>
  <p>What I run in the shell :( sudo systemctl start redis ) then   <strong>celery -A demo worker -l debug</strong></p>
  <p>output :</p>
  <pre><code> -------------- celery@laptop v4.4.6 (cliffs)
   --- ***** ----- 
   -- ******* ---- Linux-5.7.9-arch1-1-x86_64-with-glibc2.2.5 2020-07-20 17:23:51
   - *** --- * --- 
   - ** ---------- [config]
   - ** ---------- .&gt; app:         demo:0x7f0d73fd67c0
   - ** ---------- .&gt; transport:   redis://localhost:6379/0
  - ** ---------- .&gt; results:     disabled://
  - *** --- * --- .&gt; concurrency: 4 (prefork)
   -- ******* ---- .&gt; task events: OFF (enable -E to monitor tasks in this worker)
  --- ***** ----- 
    -------------- [queues]
              .&gt; celery           exchange=celery(direct) key=celery
  </code></pre>
  <p><strong>celery flower -A demo</strong></p>
  <pre><code>[I 200720 17:26:27 command:138] Visit me at http://localhost:5555
  [I 200720 17:26:27 command:145] Broker: redis://localhost:6379/0
  [I 200720 17:26:27 command:146] Registered tasks: 
  ['celery.accumulate',
   'celery.backend_cleanup',
   'celery.chain',
   'celery.chord',
   'celery.chord_unlock',
   'celery.chunks',
   'celery.group',
   'celery.map',
   'celery.starmap',
   'demo.tasks.resize_book_celery']
  </code></pre>
  <p>When I submit the form i got an endless loading without error message and get nothing in flower's dashboard. It was working fine this morning, I first thought i messed up with the code while saving but I rewrite it from scratch two times in different virtual environment and i get the same result, I also reinstalled redis from the arch repository.
  Since I don't really know much about celery/redis i then thought there were some tasks waiting in queue blocking the others so I typed some commands to purge, but nothing helps, thanks in advance if yoiu have a clue !!</p>