pyvmomi
pyvmomi copied to clipboard
Hit exception from "pyVpx/pyVim/task.py", line 121, in WaitForTask raise http.client.HTTPException: 408 Request Timeout
I'm triggering host enter maintenance mode API -> waitForTask via pyvmomi, this task would complete in 24 hour in VC since the heavy load, but watiForTask always fail in 8 hours with below exception
xxx/lib/vsphere/task.py", line 24, in waitTask
WaitForTask(task)
File "/usr/lib/python3.7/site-packages/pyVpx/pyVim/task.py", line 121, in WaitForTask
version, state = GetTaskStatus(task, version, pc)
File "/usr/lib/python3.7/site-packages/pyVpx/pyVim/task.py", line 244, in GetTaskStatus
update = pc.WaitForUpdates(version)
File "/usr/lib/python3.7/site-packages/pyVpx/pyVmomi/VmomiSupport.py", line 556, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "/usr/lib/python3.7/site-packages/pyVpx/pyVmomi/VmomiSupport.py", line 368, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/usr/lib/python3.7/site-packages/pyVpx/pyVmomi/SoapAdapter.py", line 1484, in InvokeMethod
raise six.moves.http_client.HTTPException("%d %s" % (resp.status, resp.reason))
http.client.HTTPException: 408 Request Timeout
Could you help provide some insight about this issue and how to fix it? Thanks.
you can try to rewrite the function WaitForTask and on line 189 use WaitForUpdatesEx instead of WaitForUpdates
try:
version, state = None, None
# Loop looking for updates till the state moves to a completed state.
while len(progressUpdaters):
update = pc.WaitForUpdates(version)
for filterSet in update.filterSet:
for objSet in filterSet.objectSet:
task = objSet.obj
taskId = str(task)
for change in objSet.changeSet:
if change.name == 'info':
state = change.val.state
elif change.name == 'info.state':
state = change.val
else:
continue
progressUpdater = progressUpdaters.get(taskId)
if not progressUpdater:
continue
if state == vim.TaskInfo.State.success:
progressUpdater.Update('completed')
progressUpdaters.pop(taskId)
# cache the results, as task objects could expire if one
# of the tasks take a longer time to complete
results.append(task.info.result)
elif state == vim.TaskInfo.State.error:
err = task.info.error
progressUpdater.Update('error: %s' % str(err))
if raiseOnError:
raise err
else:
print("Task %s reported error: %s" % (taskId, str(err)))
progressUpdaters.pop(taskId)
else:
if onProgressUpdate:
progressUpdater.UpdateIfNeeded()
# Move to next version
version = update.version
the api doc https://code.vmware.com/apis/42/vsphere/doc/vmodl.query.PropertyCollector.html#waitForUpdates