Skip to content

Commit fc4e296

Browse files
committed
Don't check acquire the eval context's lock in DALI's background thread
Signed-off-by: Rostan Tabet <rtabet@nvidia.com>
1 parent 2acd546 commit fc4e296

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

dali/python/nvidia/dali/experimental/dynamic/_eval_context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def _is_current(self) -> bool:
210210
return self is _tls.default.get(current_device_id)
211211

212212
def __enter__(self):
213-
if not self._lock.acquire(blocking=False):
213+
if not self._is_in_background_thread() and not self._lock.acquire(blocking=False):
214214
raise RuntimeError("An EvalContext cannot be active in two threads simultaneously.")
215215
try:
216216
_tls.stack.append(self)
@@ -235,7 +235,8 @@ def __exit__(self, exc_type, exc_value, traceback):
235235
if self._device:
236236
self._device.__exit__(exc_type, exc_value, traceback)
237237
finally:
238-
self._lock.release()
238+
if not self._is_in_background_thread():
239+
self._lock.release()
239240

240241
def evaluate_all(self):
241242
"""Evaluates all pending invocations."""

0 commit comments

Comments
 (0)