Skip to content

Commit 409f304

Browse files
committed
Update the threading guide to reflect the fact that exceptins are raised
Signed-off-by: Rostan Tabet <rtabet@nvidia.com>
1 parent e67bcd2 commit 409f304

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

docs/dali_dynamic/threading.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ threads.
1919
:octicon:`alert-fill;1.2em;align-text-bottom text-warning` Multiple threads using the same :class:`EvalContext`:
2020

2121
.. code-block:: python
22-
:emphasize-lines: 4
22+
:emphasize-lines: 7
2323
2424
import threading
2525
import nvidia.dali.experimental.dynamic as ndd
2626
2727
ctx = ndd.EvalContext(num_threads=4)
2828
2929
def worker():
30-
with ctx: # Bad: using the same EvalContext in multiple threads simultaneously
30+
with ctx: # Raises an exception
3131
img = ndd.random.uniform(shape=(100, 100, 3), range=(0, 255), dtype=ndd.uint8)
3232
flipped = ndd.flip(img, horizontal=True)
3333
...
@@ -39,10 +39,12 @@ threads.
3939
t.join()
4040
4141
Here, the code should either create an instance of the evaluation context per thread, or use
42-
:func:`set_num_threads`. Here's a corrected version:
42+
:func:`set_num_threads`.
43+
44+
:octicon:`check-circle-fill;1.2em;align-text-bottom text-success` Correct code using
45+
:func:`set_num_threads`:
4346

4447
.. code-block:: python
45-
:emphasize-lines: 4
4648
4749
import threading
4850
import nvidia.dali.experimental.dynamic as ndd

0 commit comments

Comments
 (0)