Skip to content

Commit

Permalink
NEWS
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Jul 5, 2023
1 parent c6c9c13 commit 9b51776
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# reticulate (development version)

- `py_iterator()` gains a `prefetch` argument, primarily to avoid deadlocks
in situations where a background thread is attempting to use the iterator
while the main thread is fully blocked (as encountered in TensorFlow).
where the main thread is blocked, waiting for the iterator, which is waiting
to run on the main thread, as encountered in TensorFlow/Keras. (#1405).

- The knitr engine gains a `jupyter_compat` option, enabling
reticulate to better match the behavior of Jupyter. When this chunk
Expand Down
14 changes: 6 additions & 8 deletions inst/python/rpytools/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ def _tend_queue(self, min_fetch=0):

## Prefetch and enqueue generator generated values.

# If we're not on the main thread, register a pending call to
# this function from the py main thread and return.
if (
not self._pending_tend_queue
and threading.current_thread() is not threading.main_thread()
):
self._pending_tend_queue = True
rpycall.call_python_function_on_main_thread(self._tend_queue, min_fetch)
# If we're not on the main thread, make sure there is a pending call to
# this function from the main thread and return.
if threading.current_thread() is not threading.main_thread():
if not self._pending_tend_queue:
self._pending_tend_queue = True
rpycall.call_python_function_on_main_thread(self._tend_queue, min_fetch)
return

# We're on the main thread, call the generator and put values on the queue.
Expand Down

0 comments on commit 9b51776

Please sign in to comment.