<h1 dir="auto">Checklist</h1>

<ul dir="auto">
<li>[x ] I have checked the <a href="https://github.com/celery/celery/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+label%3A%22Category%3A+Documentation%22+">issues list</a><br>
for similar or identical bug reports.</li>
<li>[x ] I have checked the <a href="https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed fixes.</li>
<li>[x ] I have checked the <a href="https://github.com/celery/celery/commits/master">commit log</a><br>
to find out if the bug was already fixed in the master branch.</li>
<li>[x ] I have included all related issues and possible duplicate issues in this issue<br>
(If there are none, check this box anyway).</li>
</ul>
<p dir="auto">Currently using <code class="notranslate">Celery 4.2.1</code> with <code class="notranslate">Redis 2.10.6</code>.</p>
<h1 dir="auto">Description</h1>
<p dir="auto">I have two workers, <code class="notranslate">backgroundworker</code> which consumes the queues <code class="notranslate">regular</code> and <code class="notranslate">important</code>, and <code class="notranslate">importantworker</code> which consumers only the queue <code class="notranslate">important</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="backgroundworker: celery -A my_app worker -c 6 -Q regular, important -l info -Ofair 
importantworker: celery -A my_app worker -c 6 -Q important -l info -Ofair "><pre class="notranslate"><code class="notranslate">backgroundworker: celery -A my_app worker -c 6 -Q regular, important -l info -Ofair 
importantworker: celery -A my_app worker -c 6 -Q important -l info -Ofair 
</code></pre></div>
<p dir="auto">There are instances when there are already 1000s of tasks being sent to the <code class="notranslate">regular</code> queue, and therefore handled exclusively by <code class="notranslate">backgroundworker</code>, but when a task is sent to the <code class="notranslate">important</code> queue, it is still handled by <code class="notranslate">backgroundworker</code> and not by <code class="notranslate">importantworker</code>, even though the former should be "busy" (or busier..).</p>
<p dir="auto">Is this intended? anyway to mitigate that? I was pretty sure that before Celery would route this task to the worker which was consuming less tasks (in this case <code class="notranslate">importantworker</code>), in hopes to "balance the load".</p>
<h1 dir="auto">Suggestions</h1>
<p dir="auto">If this is intended, is there anywhere where I can read more about how Celery routes tasks in this scenario? (this scenario: multiple separate workers sharing some of their queues, not the other way around)</p>
<h1 dir="auto">Checklist</h1>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> This has already been asked to the <a href="https://github.com/celery/celery/discussions">discussions forum</a> first.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the relevant section in the<br>
<a href="http://docs.celeryproject.org/en/latest/contributing.html#other-bugs" rel="nofollow">contribution guide</a><br>
on reporting bugs.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Bug+Report%22+-label%3A%22Category%3A+Documentation%22">issues list</a><br>
for similar or identical bug reports.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22PR+Type%3A+Bugfix%22+-label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed fixes.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/commits/master">commit log</a><br>
to find out if the bug was already fixed in the master branch.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included all related issues and possible duplicate issues<br>
in this issue (If there are none, check this box anyway).</li>
</ul>
<h2 dir="auto">Mandatory Debugging Information</h2>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included the output of <code class="notranslate">celery -A proj report</code> in the issue.<br>
(if you are not able to do this, then at least specify the Celery<br>
version affected).</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have verified that the issue exists against the <code class="notranslate">master</code> branch of Celery.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included the contents of <code class="notranslate">pip freeze</code> in the issue.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included all the versions of all the external dependencies required<br>
to reproduce this bug.</li>
</ul>
<h2 dir="auto">Optional Debugging Information</h2>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have tried reproducing the issue on more than one Python version<br>
and/or implementation.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have tried reproducing the issue on more than one message broker and/or<br>
result backend.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one version of the message<br>
broker and/or result backend.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one operating system.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue on more than one workers pool.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue with autoscaling, retries,<br>
ETA/Countdown &amp; rate limits disabled.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have tried reproducing the issue after downgrading<br>
and/or upgrading Celery and its dependencies.</li>
</ul>
<h2 dir="auto">Related Issues and Possible Duplicates</h2>

<h4 dir="auto">Related Issues</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h4 dir="auto">Possible Duplicates</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h2 dir="auto">Environment &amp; Settings</h2>

<p dir="auto"><strong>Celery version</strong>:</p>

<details>
<summary><b><code class="notranslate">celery report</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="software -&gt; celery:5.2.3 (dawn-chorus) kombu:5.2.3 py:3.7.12
            billiard:3.6.4.0 N/A:N/A
platform -&gt; system:Linux arch:64bit
            kernel version:5.10.16.3-microsoft-standard-WSL2 imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:azureservicebus results:azureblockblob://REDACTED

broker_url: 'azureservicebus://RootManageSharedAccessKey:********@REDACTED'
result_backend: 'azureblockblob://REDACTED'
azureblockblob_container_name: 'celery-result-store'
deprecated_settings: None"><pre class="notranslate"><code class="notranslate">software -&gt; celery:5.2.3 (dawn-chorus) kombu:5.2.3 py:3.7.12
            billiard:3.6.4.0 N/A:N/A
platform -&gt; system:Linux arch:64bit
            kernel version:5.10.16.3-microsoft-standard-WSL2 imp:CPython
loader   -&gt; celery.loaders.app.AppLoader
settings -&gt; transport:azureservicebus results:azureblockblob://REDACTED

broker_url: 'azureservicebus://RootManageSharedAccessKey:********@REDACTED'
result_backend: 'azureblockblob://REDACTED'
azureblockblob_container_name: 'celery-result-store'
deprecated_settings: None
</code></pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Steps to Reproduce</h1>
<h2 dir="auto">Required Dependencies</h2>

<ul dir="auto">
<li><strong>Minimal Python Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Celery Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Kombu Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Broker Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Result Backend Version</strong>: N/A or Unknown</li>
<li><strong>Minimal OS and/or Kernel Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Broker Client Version</strong>: N/A or Unknown</li>
<li><strong>Minimal Result Backend Client Version</strong>: N/A or Unknown</li>
</ul>
<h3 dir="auto">Python Packages</h3>

<details>
<summary><b><code class="notranslate">pip freeze</code> Output:</b></summary>
<p dir="auto">
</p><div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" amqp==5.0.9
azure-common==1.1.27
azure-core==1.21.1
azure-servicebus==7.5.0
azure-storage-blob==12.9.0
billiard==3.6.4.0
Brotli==1.0.9
cached-property==1.5.2
celery==5.2.3
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.10
click==8.0.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
cryptography==36.0.1
dash==2.0.0
dash-core-components==2.0.0
dash-extensions==0.0.67
dash-html-components==2.0.0
dash-renderer==1.4.0
dash-table==5.0.0
Deprecated==1.2.13
EditorConfig==0.12.3
Flask==2.0.2
Flask-Caching==1.10.1
Flask-Compress==1.10.1
future==0.18.2
gunicorn==20.1.0
idna==3.3
importlib-metadata==4.10.1
isodate==0.6.1
itsdangerous==2.0.1
Jinja2==3.0.3
jsbeautifier==1.14.0
kombu==5.2.3
MarkupSafe==2.0.1
more-itertools==8.12.0
msrest==0.6.21
oauthlib==3.1.1
packaging==21.3
plotly==5.5.0
prompt-toolkit==3.0.24
pycparser==2.21
pyparsing==3.0.6
python-dotenv==0.19.2
pytz==2021.3
queues==0.6.3
redis==4.1.1
requests==2.27.1
requests-oauthlib==1.3.0
six==1.16.0
tenacity==8.0.1
typing-extensions==4.0.1
uamqp==1.5.1
urllib3==1.26.8
vine==5.0.0
wcwidth==0.2.5
Werkzeug==2.0.2
wrapt==1.13.3
zipp==3.7.0"><pre class="notranslate"><code class="notranslate"> amqp==5.0.9
azure-common==1.1.27
azure-core==1.21.1
azure-servicebus==7.5.0
azure-storage-blob==12.9.0
billiard==3.6.4.0
Brotli==1.0.9
cached-property==1.5.2
celery==5.2.3
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.10
click==8.0.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
cryptography==36.0.1
dash==2.0.0
dash-core-components==2.0.0
dash-extensions==0.0.67
dash-html-components==2.0.0
dash-renderer==1.4.0
dash-table==5.0.0
Deprecated==1.2.13
EditorConfig==0.12.3
Flask==2.0.2
Flask-Caching==1.10.1
Flask-Compress==1.10.1
future==0.18.2
gunicorn==20.1.0
idna==3.3
importlib-metadata==4.10.1
isodate==0.6.1
itsdangerous==2.0.1
Jinja2==3.0.3
jsbeautifier==1.14.0
kombu==5.2.3
MarkupSafe==2.0.1
more-itertools==8.12.0
msrest==0.6.21
oauthlib==3.1.1
packaging==21.3
plotly==5.5.0
prompt-toolkit==3.0.24
pycparser==2.21
pyparsing==3.0.6
python-dotenv==0.19.2
pytz==2021.3
queues==0.6.3
redis==4.1.1
requests==2.27.1
requests-oauthlib==1.3.0
six==1.16.0
tenacity==8.0.1
typing-extensions==4.0.1
uamqp==1.5.1
urllib3==1.26.8
vine==5.0.0
wcwidth==0.2.5
Werkzeug==2.0.2
wrapt==1.13.3
zipp==3.7.0
</code></pre></div>
<p dir="auto"></p>
</details>
<h3 dir="auto">Other Dependencies</h3>

<details>
<p dir="auto">
N/A
</p>
</details>
<h2 dir="auto">Minimally Reproducible Test Case</h2>

<details>
<p dir="auto">
</p><div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"></pre></div>
<p dir="auto"></p>
</details>
<h1 dir="auto">Expected Behavior</h1>
<p dir="auto">No error</p>
<h1 dir="auto">Actual Behavior</h1>
<p dir="auto">I am trying to setup celery using the <code class="notranslate">azureservicebus</code> broker option. If I use <code class="notranslate">redis</code> (or <code class="notranslate">rabbitmq</code>) as the broker, my code works, but when I try to use <code class="notranslate">azureservicebus</code> I get the following error,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2022-01-19 12:53:44,400: ERROR/MainProcess] Task handler raised error: TypeError('no default __reduce__ due to non-trivial __cinit__')
Traceback (most recent call last):
  File &quot;/.../venv/lib/python3.9/site-packages/billiard/pool.py&quot;, line 596, in body
    put(task)
  File &quot;/.../venv/lib/python3.9/site-packages/billiard/connection.py&quot;, line 233, in send
    self._send_bytes(ForkingPickler.dumps(obj))
  File &quot;/.../venv/lib/python3.9/site-packages/billiard/reduction.py&quot;, line 56, in dumps
    cls(buf, protocol).dump(obj)
  File &quot;stringsource&quot;, line 2, in uamqp.c_uamqp.CompositeValue.__reduce_cython__
TypeError: no default __reduce__ due to non-trivial __cinit__"><pre class="notranslate"><code class="notranslate">[2022-01-19 12:53:44,400: ERROR/MainProcess] Task handler raised error: TypeError('no default __reduce__ due to non-trivial __cinit__')
Traceback (most recent call last):
  File "/.../venv/lib/python3.9/site-packages/billiard/pool.py", line 596, in body
    put(task)
  File "/.../venv/lib/python3.9/site-packages/billiard/connection.py", line 233, in send
    self._send_bytes(ForkingPickler.dumps(obj))
  File "/.../venv/lib/python3.9/site-packages/billiard/reduction.py", line 56, in dumps
    cls(buf, protocol).dump(obj)
  File "stringsource", line 2, in uamqp.c_uamqp.CompositeValue.__reduce_cython__
TypeError: no default __reduce__ due to non-trivial __cinit__
</code></pre></div>
<p dir="auto">I have debugged the issue and found that the error occurs when the <code class="notranslate">billiard.reduction.ForkingPickler.dumps</code> function is called on the <code class="notranslate">azure.servicebus.ServiceBusReceivedMessage</code>  object. It this seems to be an issue with this object not supporting the serialization protocol.</p>
<p dir="auto">As a side note, I tested my connection string using the <a href="https://docs.celeryproject.org/projects/kombu/en/latest/userguide/examples.html" rel="nofollow">kombu examples</a>, and they work. So I guess the issue shouldn't be related to my azureservicebus configuration. I also tried different Python version (3.7 and 3.9).</p>