Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
4f65f91d
You need to sign in or sign up before continuing.
Unverified
Commit
4f65f91d
authored
Sep 07, 2023
by
Haobo Yuan
Committed by
GitHub
Sep 07, 2023
Browse files
[Fix] Fix data race risk of `cache_randomness` (#2927)
parent
c0268ad9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
mmcv/transforms/utils.py
mmcv/transforms/utils.py
+5
-1
No files found.
mmcv/transforms/utils.py
View file @
4f65f91d
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
import
copy
import
functools
import
functools
import
inspect
import
inspect
import
weakref
import
weakref
...
@@ -80,7 +81,10 @@ class cache_randomness:
...
@@ -80,7 +81,10 @@ class cache_randomness:
def
__get__
(
self
,
obj
,
cls
):
def
__get__
(
self
,
obj
,
cls
):
self
.
instance_ref
=
weakref
.
ref
(
obj
)
self
.
instance_ref
=
weakref
.
ref
(
obj
)
return
self
# Return a copy to avoid multiple transform instances sharing
# one `cache_randomness` instance, which may cause data races
# in multithreading cases.
return
copy
.
copy
(
self
)
def
avoid_cache_randomness
(
cls
):
def
avoid_cache_randomness
(
cls
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment