1

我正在将 azure-sdk 用于 python,特别是 azure-servicebus 0.50.0

from azure.servicebus import QueueClient
service_bus_queue_connectionString= "my service bus string"
service_bus_queue_name ="service bus queue"
queue_client = QueueClient.from_connection_string(service_bus_queue_connectionString, service_bus_queue_name)
sessions= queue_client.list_sessions() print(sessions)

使用以下代码时,我收到以下错误

发生了溢出错误类型的异常。参数:('mktime 参数超出范围',)

可能的原因是什么?

编辑请找到堆栈跟踪。任何帮助,将不胜感激。

File "C:\Users\NewtonCode\Desktop\EY.TPBML.PY - Copy\model_engine.py", line 28, in start_process
    sessions = self.queue_client.list_sessions()
  File "C:\Users\NewtonCode\AppData\Local\Continuum\anaconda3\lib\site-packages\azure\servicebus\servicebus_client.py", line 469, in list_sessions
    mgmt_handlers.list_sessions_op)
  File "C:\Users\NewtonCode\AppData\Local\Continuum\anaconda3\lib\site-packages\azure\servicebus\base_handler.py", line 83, in _mgmt_request_response
    **kwargs))
  File "C:\Users\NewtonCode\AppData\Local\Continuum\anaconda3\lib\site-packages\uamqp\message.py", line 109, in __init__
    self._body.set(body)
  File "C:\Users\NewtonCode\AppData\Local\Continuum\anaconda3\lib\site-packages\uamqp\message.py", line 913, in set
    value = utils.data_factory(value)
  File "C:\Users\NewtonCode\AppData\Local\Continuum\anaconda3\lib\site-packages\uamqp\utils.py", line 108, in data_factory
    wrapped_dict[data_factory(key, encoding=encoding)] = data_factory(item, encoding=encoding)
  File "C:\Users\NewtonCode\AppData\Local\Continuum\anaconda3\lib\site-packages\uamqp\utils.py", line 117, in data_factory
    timestamp = int((time.mktime(value.utctimetuple()) * 1000) + (value.microsecond/1000))
OverflowError: mktime argument out of range
4

1 回答 1

3

感谢您提出这个问题 - 它看起来像是库中的一个错误。

虽然不是解决方案 - 我在这里的底层 uAMQP 库中打开了一个问题: https ://github.com/Azure/azure-uamqp-python/issues/63

同时,您可以通过将“updated-since”时间戳传入 list_sessions 操作来解决此问题:

# Start time of a week ago - replace with appropriate value
start_time = datetime.datetime.now() - datetime.timedelta(weeks=1)
sessions = queue_client.list_sessions(updated_since=start_time)

再次感谢,我会尽快发布修复!:)

于 2019-03-27T14:13:14.603 回答