mktime参数超出范围

时间:2019-03-26 12:29:02

标签: python azure azureservicebus azure-sdk-python

我正在将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)

使用以下代码时,出现以下错误

  

发生类型为OverflowError的异常。参数:('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

1 个答案:

答案 0 :(得分:2)

感谢提出这个问题-好像是库中的错误。

虽然不是解决方案-我在下面的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)

再次感谢,我将尽快发布修复程序! :)