vmware / vmware/pyvmomi

copy.deepcopy() fails when using a SessionOrientedStub

Open
#1,093 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

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('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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided example, then inspect pyVim.connect.VimSessionOrientedStub and the deepcopy-related handling for pyVmomi.SoapStubAdapter. Done means copy.deepcopy() succeeds for a ServiceInstance created with either stub, including the session-oriented stub.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.