-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1648 from rstudio/positron-repl_python
Update `repl_python()` to use independent Console session in Positron
- Loading branch information
Showing
24 changed files
with
627 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ __pycache__ | |
^\.dockerignore$ | ||
^\.git-blame-ignore-revs$ | ||
^rchk$ | ||
^\.cache$ | ||
^compile_commands\.json$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,6 @@ README.html | |
index.html | ||
inst/doc | ||
.vscode/ | ||
rchk | ||
rchk | ||
.cache | ||
compile_commands.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
import rpycall | ||
import threading | ||
|
||
import sys | ||
import queue as queue | ||
from rpycall import call_r_function, schedule_python_function_on_main_thread | ||
|
||
is_py2 = sys.version[0] == "2" | ||
if is_py2: | ||
import Queue as queue | ||
else: | ||
import queue as queue | ||
|
||
|
||
def main_thread_func(f): | ||
|
||
def python_function(*args, **kwargs): | ||
|
||
if isinstance(threading.current_thread(), threading._MainThread): | ||
res = f(*args, **kwargs) | ||
else: | ||
result = queue.Queue() | ||
rpycall.call_python_function_on_main_thread( | ||
lambda: result.put(f(*args, **kwargs)), None | ||
) | ||
res = result.get() | ||
def safe_call_r_function(f, args, kwargs): | ||
try: | ||
return call_r_function(f, *args, **kwargs), None | ||
except Exception as e: # TODO: should we catch BaseException too? KeyboardInterrupt? | ||
return None, e | ||
|
||
return res | ||
|
||
return python_function | ||
def safe_call_r_function_on_main_thread(f, *args, **kwargs): | ||
result = queue.Queue() | ||
schedule_python_function_on_main_thread( | ||
lambda: result.put(safe_call_r_function(f, args, kwargs)), | ||
None, | ||
) | ||
return result.get() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.