pyvmomi
pyvmomi copied to clipboard
copy.deepcopy() fails when using a SessionOrientedStub
Describe the bug
Attempting to use copy.deepcopy() fails when using a pyVim.connect.VimSessionOrientedStub, while (since the fix introduced in a90023fedfeda48cb1824200dc4530084215f99e) it works correctly for the bare pyVmomi.SoapStubAdapter.
Reproduction steps
>>> import copy, pyVim.connect, pyVmomi
>>> stub = pyVim.connect.VimSessionOrientedStub(
... pyVim.connect.SmartStubAdapter(host='vcenter.example', disableSslCertValidation=True),
... pyVim.connect.VimSessionOrientedStub.makeUserLoginMethod('[email protected]', 'swordfish'))
>>> copy.deepcopy(pyVmomi.vim.ServiceInstance('ServiceInstance', stub.soapStub))
'vim.ServiceInstance:ServiceInstance'
>>> copy.deepcopy(pyVmomi.vim.ServiceInstance('ServiceInstance', stub))
[...]
TypeError: cannot pickle '_thread.lock' object
Expected behavior
copy.deepcopy() should work equally well for SoapStubAdapters and VimSessionOrientedStubs.
Additional context
Tested on 8.0.2.0.1, but I see no relevant code changes since then.