Skip to content

copy.deepcopy() fails when using a SessionOrientedStub #1093

@alexshpilkin

Description

@alexshpilkin

Describe the bug

Attempting to use copy.deepcopy() fails when using a pyVim.connect.VimSessionOrientedStub, while (since the fix introduced in a90023f) 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('administrator@vsphere.local', '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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions