Azure / azure-uamqp-python

AMQP 1.0 client library for Python
MIT License
56 stars 48 forks source link

fix async cbs error #272

Closed yunhaoling closed 2 years ago

yunhaoling commented 2 years ago

the latest code in the master branch would result in the following error:

Traceback (most recent call last):
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\azure\eventhub\aio\_client_base_async.py", line 487, in _do_retryable_operation
    return await operation()
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\azure\eventhub\aio\_client_base_async.py", line 438, in _open
    self._client._address.hostname, auth
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\uamqp-1.4.2-py3.7-win-amd64.egg\uamqp\async_ops\client_async.py", line 241, in open_async
    await self._build_session_async()
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\uamqp-1.4.2-py3.7-win-amd64.egg\uamqp\async_ops\client_async.py", line 192, in _build_session_async
    **self._internal_kwargs)
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\uamqp-1.4.2-py3.7-win-amd64.egg\uamqp\authentication\cbs_auth_async.py", line 283, in create_authenticator_async
    kwargs.update(self._internal_kwargs)
AttributeError: 'JWTTokenAsync' object has no attribute '_internal_kwargs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/Projects/azure-sdk-for-python/sdk/eventhub/azure-eventhub/samples/async_samples/send_async.py", line 107, in <module>
    loop.run_until_complete(run())
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\asyncio\base_events.py", line 587, in run_until_complete
    return future.result()
  File "D:/Projects/azure-sdk-for-python/sdk/eventhub/azure-eventhub/samples/async_samples/send_async.py", line 97, in run
    await send_event_data_batch(producer)
  File "D:/Projects/azure-sdk-for-python/sdk/eventhub/azure-eventhub/samples/async_samples/send_async.py", line 29, in send_event_data_batch
    event_data_batch = await producer.create_batch()
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\azure\eventhub\aio\_producer_client_async.py", line 355, in create_batch
    await self._get_max_mesage_size()
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\azure\eventhub\aio\_producer_client_async.py", line 119, in _get_max_mesage_size
    EventHubProducer, self._producers[ALL_PARTITIONS]
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\azure\eventhub\aio\_producer_async.py", line 119, in _open_with_retry
    self._open, operation_need_param=False
  File "C:\Users\yuling\Anaconda3\envs\env37\lib\site-packages\azure\eventhub\aio\_client_base_async.py", line 505, in _do_retryable_operation
    raise last_exception
azure.eventhub.exceptions.EventHubError: 'JWTTokenAsync' object has no attribute '_internal_kwargs'
'JWTTokenAsync' object has no attribute '_internal_kwargs'

Process finished with exit code 1

Root cause: self._internal_kwargs is not available on the JWTTokenAsync before calling create_authenticator_async which leads to the error. The fix should be simple, let the parent call handle to kwargs/loop.

However, I'm curious why it is not detected by the integrated livetest of EH/SB within in the uamqp livetest pipeline at the first place. Maybe our livetest pipeline has a bug.

yunhaoling commented 2 years ago

@swathipil , I'll merge my PRs, generate wheels and use my old way (upload to a blob, and specify the uamqp wheel url to install in EH/SB livetest pipeline) to verify the uamqp changes first before we verify/fix the uamqp livetest pipeline. 😉

I have created a separate issue: https://github.com/Azure/azure-uamqp-python/issues/273