Celery `AsyncResult.state` hangs in `PENDING` (ubuntu)

Considering a task

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>from celery import Celery
from django.conf import settings
app = Celery(
'api',
broker=settings.CELERY_BROKER_URL,
backend=settings.CELERY_BROKER_URL,
timezone=settings.CELERY_TIMEZONE,
task_track_started=settings.CELERY_TASK_TRACK_STARTED,
task_time_limit=settings.CELERY_TASK_TIME_LIMIT,
broker_connection_retry_on_startup=settings.CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP,
)
# This would fail to connect because I couldn't get TLS to work this way
# app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
@app.task(queue='periodic')
def some_task(corpus_id):
return 123
</code>
<code>from celery import Celery from django.conf import settings app = Celery( 'api', broker=settings.CELERY_BROKER_URL, backend=settings.CELERY_BROKER_URL, timezone=settings.CELERY_TIMEZONE, task_track_started=settings.CELERY_TASK_TRACK_STARTED, task_time_limit=settings.CELERY_TASK_TIME_LIMIT, broker_connection_retry_on_startup=settings.CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP, ) # This would fail to connect because I couldn't get TLS to work this way # app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() @app.task(queue='periodic') def some_task(corpus_id): return 123 </code>
from celery import Celery
from django.conf import settings

app = Celery(
    'api',
    broker=settings.CELERY_BROKER_URL,
    backend=settings.CELERY_BROKER_URL,
    timezone=settings.CELERY_TIMEZONE,
    task_track_started=settings.CELERY_TASK_TRACK_STARTED,
    task_time_limit=settings.CELERY_TASK_TIME_LIMIT,
    broker_connection_retry_on_startup=settings.CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP,
    
)

# This would fail to connect because I couldn't get TLS to work this way
# app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

@app.task(queue='periodic')
def some_task(corpus_id):
    return 123

A submitted task is (and stays) PENDING.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>r = some_task.apply_async([4], queue='gpu')
r.state == 'PENDING'
</code>
<code>r = some_task.apply_async([4], queue='gpu') r.state == 'PENDING' </code>
r = some_task.apply_async([4], queue='gpu')
r.state == 'PENDING'

Nothing is logged in the worker:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>-------------- celery@gpuworker v5.4.0 (opalescent)
--- ***** -----
-- ******* ---- Linux-5.15.0-118-generic-x86_64-with-glibc2.39 2024-09-10 21:55:59
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app: api:0x7ff754494700
- ** ---------- .> transport: rediss://redis:6379/1
- ** ---------- .> results: rediss://redis:6379/1
- *** --- * --- .> concurrency: 1 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> gpu exchange=gpu(direct) key=gpu
[tasks]
. api.celery.some_task
[2024-09-10 21:55:59,900: INFO/MainProcess] Connected to rediss://redis:6379/1
[2024-09-10 21:55:59,974: INFO/MainProcess] mingle: searching for neighbors
[2024-09-10 21:56:01,098: INFO/MainProcess] mingle: all alone
[2024-09-10 21:56:01,406: INFO/MainProcess] celery@gpuworker ready.
</code>
<code>-------------- celery@gpuworker v5.4.0 (opalescent) --- ***** ----- -- ******* ---- Linux-5.15.0-118-generic-x86_64-with-glibc2.39 2024-09-10 21:55:59 - *** --- * --- - ** ---------- [config] - ** ---------- .> app: api:0x7ff754494700 - ** ---------- .> transport: rediss://redis:6379/1 - ** ---------- .> results: rediss://redis:6379/1 - *** --- * --- .> concurrency: 1 (prefork) -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) --- ***** ----- -------------- [queues] .> gpu exchange=gpu(direct) key=gpu [tasks] . api.celery.some_task [2024-09-10 21:55:59,900: INFO/MainProcess] Connected to rediss://redis:6379/1 [2024-09-10 21:55:59,974: INFO/MainProcess] mingle: searching for neighbors [2024-09-10 21:56:01,098: INFO/MainProcess] mingle: all alone [2024-09-10 21:56:01,406: INFO/MainProcess] celery@gpuworker ready. </code>
-------------- celery@gpuworker v5.4.0 (opalescent)
--- ***** ----- 
-- ******* ---- Linux-5.15.0-118-generic-x86_64-with-glibc2.39 2024-09-10 21:55:59
- *** --- * --- 
- ** ---------- [config]
- ** ---------- .> app:         api:0x7ff754494700
- ** ---------- .> transport:   rediss://redis:6379/1
- ** ---------- .> results:     rediss://redis:6379/1
- *** --- * --- .> concurrency: 1 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** ----- 
 -------------- [queues]
                .> gpu              exchange=gpu(direct) key=gpu
                

[tasks]
  . api.celery.some_task

[2024-09-10 21:55:59,900: INFO/MainProcess] Connected to rediss://redis:6379/1
[2024-09-10 21:55:59,974: INFO/MainProcess] mingle: searching for neighbors
[2024-09-10 21:56:01,098: INFO/MainProcess] mingle: all alone
[2024-09-10 21:56:01,406: INFO/MainProcess] celery@gpuworker ready.

I checked if the job is somewhere in app.control.inspect():

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>i = app.control.inspect()
i.reserved(), i.active(), i.registered(), i.scheduled()
# (None, None, None, None)
</code>
<code>i = app.control.inspect() i.reserved(), i.active(), i.registered(), i.scheduled() # (None, None, None, None) </code>
i = app.control.inspect()
i.reserved(), i.active(), i.registered(), i.scheduled()
# (None, None, None, None)

Because there’s no exception, error, log entry in the worker, etc, I’m clueless where to begin debugging this. Is there some way to debug this? Is it fair to assume the redis connection works, since if there were connection issues, there would have been an exception on apply_async or at least the state would become FAILED at some point? Can I check things in the AsyncResult r (r.failed() == False and r.ready() == False)? Why isn’t this listed in any of the app‘s inspect?

I also checked that app and some_task.app are the same, to ensure I’m not comparing apples and oranges:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><Celery api at 0x7f26e52b71c0>
<Celery api at 0x7f26e52b71c0>
</code>
<code><Celery api at 0x7f26e52b71c0> <Celery api at 0x7f26e52b71c0> </code>
<Celery api at 0x7f26e52b71c0>
<Celery api at 0x7f26e52b71c0>

A solution of course would be great, but I would already be very happy to have some sanity checks or inspection suggestions.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật