We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 60ae629 commit 4e5b5b7Copy full SHA for 4e5b5b7
ml-agents/mlagents/trainers/torch/model_serialization.py
@@ -19,14 +19,20 @@ class exporting_to_onnx:
19
This implementation is thread safe.
20
"""
21
22
+ # local is_exporting flag for each thread
23
_local_data = threading.local()
24
_local_data._is_exporting = False
25
26
+ # global lock shared among all threads, to make sure only one thread is exporting at a time
27
+ _lock = threading.Lock()
28
+
29
def __enter__(self):
30
+ self._lock.acquire()
31
self._local_data._is_exporting = True
32
33
def __exit__(self, *args):
34
self._local_data._is_exporting = False
35
+ self._lock.release()
36
37
@staticmethod
38
def is_exporting():
0 commit comments