Repository navigation
Preserve session stubs when deep-copying managed objects - #1118
Shubham-Padkonde wants to merge 1 commit into
Conversation
🛑 Legal Compliance Check FailedHi @Shubham-Padkonde, thank you for your contribution! To merge this Pull Request, you must sign our DCO. Note: Even if you signed off your commits locally (using 1. Read the Document: Click here to read the DCO ⏳ Processing Schedule: |
|
I have read the DCO Document and I hereby sign the DCO for this and all future contributions. |
Fixes vmware#1093. Match SoapStubAdapter identity semantics so copies retain the live session instead of trying to pickle its lock. Signed-off-by: Shubham Padkonde <shubhampadkonde12@gmail.com>
438b876 to
d606340
Compare
|
Thanks for the fix and the thorough tests, @Shubham-Padkonde, and for tracking down the cause of #1093. |
|
Hi @Shubham-Padkonde. A stub adapter manages underlying connection state, sockets, and session data, making a standard Python deepcopy problematic and incomplete. Because of this, we are evaluating whether it makes more sense to deprecate or remove the existing deepcopy implementation on stubs entirely rather than extending it further. Knowing the specific workflow or issue you are addressing will help us determine the best alternative or architectural path forward. Thanks! |
Fixes #1093.
Deep-copying a managed object backed by
VimSessionOrientedStubcurrently reaches the session's thread lock and raisesTypeError: cannot pickle '_thread.lock' object. The underlyingSoapStubAdapteralready returns itself from__deepcopy__.Apply that same identity-preserving behavior to
SessionOrientedStub. Copied managed/data objects retain their original live session, lock and login state; the copy does not log in or create an independent connection.Regression tests cover the base and vim-specific session stubs, a
ServiceInstance, and aServiceContentwhose managed-object fields share the same session. The data object remains independently editable.Validation on Windows, Python 3.12.6:
python -m unittest discover tests: 41 tests passed, using the repository's pinned mock 5.2.0 and vcrpy 7.0.0 dependencies.git diff --checkpassed.The existing HTTP tests use recorded fixtures. No live vCenter/ESXi validation was performed.
Prepared and tested with OpenAI Codex assistance.