Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for Global functions and Interpreter
  • Loading branch information
nanjekyejoannah committed Mar 5, 2020
commit 2bf89d41507aab7e3daec1b558e6b69c19067913
9 changes: 5 additions & 4 deletions Doc/library/interpreters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the module going to be provisional still in 3.9 or is this going to be part of the stable API? If it's going to be provisional, I think it could include a note in the header to explain that.

--------------

This module provides tools for working with sub-interpreters, such as creating them,
running code in them, or sending data between them. It is a wrapper around the low-
level :mod:`_interpreters` module.
This module provides highlevel tools for working with sub-interpreters,
such as creating them, running code in them, or sending data between them.
It is a wrapper around the low-level :mod:`_interpreters` module.
Comment thread
nanjekyejoannah marked this conversation as resolved.
Outdated

.. versionchanged:: added in 3.9

Expand Down Expand Up @@ -124,7 +124,8 @@ This module defines the following global functions:

.. function:: get_current()

Get the currently running interpreter.
Get the currently running interpreter. This method returns
an `interpreter` object.

.. function:: list_all()

Expand Down
14 changes: 13 additions & 1 deletion Lib/interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,23 @@ def destroy(self):
def run(self, src_str, /, *, channels=None):
"""run(src_str, /, *, channels=None)

channel = (RecvChannel, SendChannel)

Run the given source code in the interpreter.
This blocks the current thread until done.
"""
if channels:
if channels[0] and channels[1] != None:
_interpreters.channel_recv(channels[0].id)
_interpreters.channel_send(channels[1].id, src_str)
elif channels[0] != None and channels[1] == None:
_interpreters.channel_recv(channels[0].id)
elif channels[0] == None and channels[1] != None:
_interpreters.channel_send(channels[1].id, src_str)
else:
pass
try:
_interpreters.run_string(self._id, src_str, channels)
_interpreters.run_string(self._id, src_str)
except RunFailedError as err:
logger.error(err)
raise
Expand Down
Loading