fix (DMSHelpers): keep the per-VO singleton through copies and pickles - #8764
Merged
Merged
Conversation
Since the method caches gained instance-level locks, deepcopying or pickling any object holding a DMSHelpers — e.g. an RMS Request, which stores one in __init__ — raised TypeError: cannot pickle '_thread.lock' object. Copies now return the shared instance and pickles reduce to the per-VO constructor lookup, which both restores copyability and stops copies from silently forking a singleton's caches and CS-derived state.
ryuwd
marked this pull request as ready for review
August 28, 2026 13:12
chrisburr
approved these changes
Aug 28, 2026
fstagni
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since v9.1.16,
copy.deepcopy()orpickle.dumps()of anyRequestobject raises:Minimal reproduction on v9.1.16:
Works fine on v9.1.15.
Cause: b11d7d9 (feat(DMSHelper): cache some methods) added per-instance
cachetoolscaches guarded by realthreading.Locks inDMSHelpers.__init__.Request.__init__stores aDMSHelperson every instance (self.dmsHelper = DMSHelpers()), so the locks are now reachable from everyRequest's object graph, anddeepcopy/picklefail via__reduce_ex__. The same applies to anything else holding aDMSHelpersinstance.This is how we found it: LHCbDIRAC's CI installs the latest DIRAC integration tag, and every pipeline started after the v9.1.16 tag now fails
Test_Modules_LHCbScript, which deepcopies aworkflow_commonsfixture containing aRequest(nothing LHCbDIRAC-side changed between the green v9.1.15 run and the red v9.1.16 run: https://gitlab.cern.ch/roneil/LHCbDIRAC/-/jobs/81172151).Fix: since 4c4260f
DMSHelpersis a per-VO singleton, so copies should never duplicate it in the first place —__copy__/__deepcopy__return the shared instance, and__reduce__pickles as "look up the per-VO singleton again on load" (thevokey is now kept on the instance). Besides restoring copyability, this stops a copy from silently forking a singleton's caches and CS-derived state.Tests cover copy/deepcopy/pickle identity plus the in-the-wild regression (deepcopy of an object embedding a helper, and of a real
Request).BEGINRELEASENOTES
*DataManagement
FIX: DMSHelpers instances stay per-VO singletons through copy, deepcopy and pickle, restoring deepcopy/pickle of objects that embed one (e.g. RMS Request)
ENDRELEASENOTES