提前致謝,我正在嘗試讓我對芹菜有點熟悉我無法解決我的問題,已經 4 個小時了我試圖找出問題所在但我無法分辨。今天早上一切正常,但現在我在提交表格時面臨無限加載。首先,我在 arch 上并使用每個包的最新版本,這是我從終端獲得的代碼和消息:配置 :演示/設置/base.py :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("REDIS_HOST")}:{config("REDIS_PORT")}/{config("REDIS_CELERY_DB")}'DATABASES = {'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db_celery__.sqlite3'),}}環境:REDIS_HOST=localhostREDIS_PORT=6379REDIS_CELERY_DB=0我的模特書籍/模型:from django.db import modelsfrom PIL import Imagefrom django import formsfrom demo import tasksdef resize_model(booquin): img = Image.open(bouquin.cover.path) if img.height > 300 or img.width > 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="cover")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 = ["titre", "cover"]我的 demo/tasks.py(我在同一個文件中混合了模型和表單,因為它只是為了測試目的)from celery import shared_taskfrom books import models@shared_taskdef resize_book_celery(book_id: int): models.resize_model(models.Bouquin.objects.get(id=book_id))我的演示/celery.py:from __future__ import absolute_import, unicode_literalsimport osfrom celery import Celery
3 回答

慕虎7371278
TA貢獻1802條經驗 獲得超4個贊
要刪除所有 Redis 數據庫的所有數據/鍵,請使用 FLUSHALL 命令。打開終端并輸入
redis-cli FLUSHALL
我認為這個問題是針對redis的。

瀟湘沐
TA貢獻1816條經驗 獲得超6個贊
我已經用這樣的超基本功能進行了測試,以查看:
@task
def time_celery(x):
return x ** 2
def multiplication_view(請求):
result = time_celery.delay(2)
context = {"result": result}
return render(request, "demo/multiplications.html", context)
我得到了同樣的無休止的加載,所以我認為 redis 肯定有問題,我想我要把我的電腦恢復到今天早上的狀態,throw rsync

心有法竹
TA貢獻1866條經驗 獲得超5個贊
切換到 rabbitmq,它似乎可以完美地工作,CELERY_BROKER_URL = 'amqp://localhost' + 啟用服務器,如此處解釋https://wiki.archlinux.org/index.php/RabbitMQ#Installation
添加回答
舉報
0/150
提交
取消