Commit d16f182
committed
fix: kick() ignores routing label when _task_queues is narrowed to 1
When with_queues() is used to narrow a broker to a single queue (e.g.
in a worker factory function), kick() hits the `len == 1` shortcut and
hardcodes the routing key to that queue's name, silently ignoring any
explicit queue_name label on the message.
This breaks the common pattern of using a multi-queue broker with
per-worker factory functions, where tasks dispatched from inside a
running task need to route to a different queue:
broker = AioPikaBroker(..., task_queues=[queue_a, queue_b, queue_c])
@broker.task(queue_name="queue_b")
async def mail_task(): ...
@broker.task # routes to queue_a by default
async def default_task():
await mail_task.kiq() # silently routed to queue_a, NOT queue_b
def get_worker_a():
return broker.with_queues(queue_a) # narrows _task_queues to 1
Fix: check the routing label first; only fall back to the single-queue
shortcut (backward-compatible) when no explicit label is present.1 parent cf89301 commit d16f182
1 file changed
Lines changed: 28 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
340 | 348 | | |
341 | 349 | | |
342 | 350 | | |
| |||
372 | 380 | | |
373 | 381 | | |
374 | 382 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
387 | 394 | | |
388 | 395 | | |
389 | 396 | | |
390 | 397 | | |
391 | 398 | | |
392 | 399 | | |
393 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
394 | 409 | | |
395 | 410 | | |
396 | 411 | | |
| |||
0 commit comments