Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

py_main_thread_func

Create a Python function that will always be called on the main thread


Description

This function is helpful when you need to provide a callback to a Python library which may invoke the callback on a background thread. As R functions must run on the main thread, wrapping the R function with py_main_thread_func() will ensure that R code is only executed on the main thread.

Usage

py_main_thread_func(f)

Arguments

f

An R function with artibrary arguments

Value

A Python function that delegates to the passed R function, which is guaranteed to always be called on the main thread.


reticulate

Interface to 'Python'

v1.20
Apache License 2.0
Authors
Kevin Ushey [aut, cre], JJ Allaire [aut], RStudio [cph, fnd], Yuan Tang [aut, cph] (<https://orcid.org/0000-0001-5243-233X>), Dirk Eddelbuettel [ctb, cph], Bryan Lewis [ctb, cph], Sigrid Keydana [ctb], Ryan Hafen [ctb, cph], Marcus Geelnard [ctb, cph] (TinyThread library, http://tinythreadpp.bitsnbites.eu/)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.