You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently in process of upgrading these three packages:
kombu 5.1.0 -> 5.3.5
celery 5.1.2 -> 5.3.6
azure-servicebus 7.8.1 -> 7.11.4
But found that Celery was throwing a TypeError when it starts up:
-------------- celery@620caf9bceb7 v5.3.6 (emerald-rush)
--- ***** -----
-- ******* ---- Linux-6.6.12-linuxkit-x86_64-with 2024-02-26 15: 36: 17
- *** --- * ---
- ** ---------- [config]
- ** ---------- .> app: my_app: 0x7ffffdc97370
- ** ---------- .> transport: azureservicebus://RootManageSharedAccessKey:my_key@my_env
- ** ---------- .> results: redis://redis:6379/
- *** --- * --- .> concurrency: 8 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
...
[tasks]
...
Traceback (most recent call last):
File "/root/.local/lib/python3.10/site-packages/celery/worker/worker.py", line 202, in start
self.blueprint.start(self)
File "/root/.local/lib/python3.10/site-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/root/.local/lib/python3.10/site-packages/celery/bootsteps.py", line 365, in start
return self.obj.start()
File "/root/.local/lib/python3.10/site-packages/celery/worker/consumer/consumer.py", line 340, in start
blueprint.start(self)
File "/root/.local/lib/python3.10/site-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/root/.local/lib/python3.10/site-packages/celery/worker/consumer/connection.py", line 21, in start
c.connection = c.connect()
File "/root/.local/lib/python3.10/site-packages/celery/worker/consumer/consumer.py", line 469, in connect
conn = self.connection_for_read(heartbeat=self.amqheartbeat)
File "/root/.local/lib/python3.10/site-packages/celery/worker/consumer/consumer.py", line 475, in connection_for_read
return self.ensure_connected(
File "/root/.local/lib/python3.10/site-packages/celery/worker/consumer/consumer.py", line 526, in ensure_connected
conn = conn.ensure_connection(
File "/root/.local/lib/python3.10/site-packages/kombu/connection.py", line 406, in ensure_connection
self._ensure_connection(*args, **kwargs)
File "/root/.local/lib/python3.10/site-packages/kombu/connection.py", line 459, in _ensure_connection
return retry_over_time(
File "/root/.local/lib/python3.10/site-packages/kombu/utils/functional.py", line 318, in retry_over_time
return fun(*args, **kwargs)
File "/root/.local/lib/python3.10/site-packages/kombu/connection.py", line 934, in _connection_factory
self._connection = self._establish_connection()
File "/root/.local/lib/python3.10/site-packages/kombu/connection.py", line 860, in _establish_connection
conn = self.transport.establish_connection()
File "/root/.local/lib/python3.10/site-packages/kombu/transport/virtual/base.py", line 975, in establish_connection
self._avail_channels.append(self.create_channel(self))
File "/root/.local/lib/python3.10/site-packages/kombu/transport/virtual/base.py", line 953, in create_channel
channel = self.Channel(connection)
File "/root/.local/lib/python3.10/site-packages/kombu/transport/azureservicebus.py", line 136, in __init__
self._try_parse_connection_string()
File "/root/.local/lib/python3.10/site-packages/kombu/transport/azureservicebus.py", line 144, in _try_parse_connection_string
if (isinstance(self._credential, DefaultAzureCredential) or
TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union
So, digging a little bit on azureservicebus.py file, it tries to import DefaultAzureCredential and ManagedIdentityCredential. If azure-identity package is not installed, kombu sets DefaultAzureCredential and ManagedIdentityCredential as vars with None value.
[...]
# line 72 to 77try:
fromazure.identityimport (DefaultAzureCredential,
ManagedIdentityCredential)
exceptImportError:
DefaultAzureCredential=NoneManagedIdentityCredential=None
[...]
Then, on _try_parse_connection_string function after parsing the URI and getting the credential, kombu checks if the credential is an instance of DefaultAzureCredential and ManagedIdentityCredential.
[...]
# line 144 to 146if (isinstance(self._credential, DefaultAzureCredential) orisinstance(self._credential, ManagedIdentityCredential)):
returnNone
[...]
The issue here is when DefaultAzureCredential and ManagedIdentityCredential are set to None, Python can't check if self._credential is an instance of None and throws a TypeError. I don't know if this is intended or not, but I did some changes on my computer and found a easy way to test it maintaining the same import strategy:
# I set the conditions on variables to have more clarity about what is being checkeddefault_azure_credential= (DefaultAzureCredentialisnotNoneandisinstance(self._credential, DefaultAzureCredential))
managed_identity_credential= (ManagedIdentityCredentialisnotNoneandisinstance(self._credential, ManagedIdentityCredential))
ifdefault_azure_credentialormanaged_identity_credential:
returnNone
I could open a PR if this is some unexpected behavior.
The text was updated successfully, but these errors were encountered:
Clarify that I am using the same configuration on Celery, Kombu and Service Bus before and after the upgrade. I also review that the check of the credential type was created on 5.3.3, so makes sense why it wasn't happening this to me before. Thanks in advance
I'm currently in process of upgrading these three packages:
kombu 5.1.0 -> 5.3.5
celery 5.1.2 -> 5.3.6
azure-servicebus 7.8.1 -> 7.11.4
But found that Celery was throwing a TypeError when it starts up:
So, digging a little bit on
azureservicebus.py
file, it tries to importDefaultAzureCredential
andManagedIdentityCredential
. Ifazure-identity
package is not installed, kombu setsDefaultAzureCredential
andManagedIdentityCredential
as vars withNone
value.Then, on
_try_parse_connection_string
function after parsing the URI and getting the credential, kombu checks if the credential is an instance ofDefaultAzureCredential
andManagedIdentityCredential
.The issue here is when
DefaultAzureCredential
andManagedIdentityCredential
are set to None, Python can't check ifself._credential
is an instance ofNone
and throws aTypeError
. I don't know if this is intended or not, but I did some changes on my computer and found a easy way to test it maintaining the same import strategy:I could open a PR if this is some unexpected behavior.
The text was updated successfully, but these errors were encountered: