summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/interpreters.py
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-02-04 01:14:43 (GMT)
committerGitHub <noreply@github.com>2023-02-04 01:14:43 (GMT)
commitc67b00534abfeca83016a00818cf1fd949613d6b (patch)
tree8e85847abe633ad261150d6885be199c036c0714 /Lib/test/support/interpreters.py
parentd4c410f0f922683f38c9d435923939d037fbd8c2 (diff)
downloadcpython-c67b00534abfeca83016a00818cf1fd949613d6b.zip
cpython-c67b00534abfeca83016a00818cf1fd949613d6b.tar.gz
cpython-c67b00534abfeca83016a00818cf1fd949613d6b.tar.bz2
gh-101524: Split Up the _xxsubinterpreters Module (gh-101526)
This is step 1 in potentially dropping all the "channel"-related code. Channels have already been removed from PEP 554. https://github.com/python/cpython/issues/101524
Diffstat (limited to 'Lib/test/support/interpreters.py')
-rw-r--r--Lib/test/support/interpreters.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/Lib/test/support/interpreters.py b/Lib/test/support/interpreters.py
index 2935708..eeff3ab 100644
--- a/Lib/test/support/interpreters.py
+++ b/Lib/test/support/interpreters.py
@@ -2,11 +2,12 @@
import time
import _xxsubinterpreters as _interpreters
+import _xxinterpchannels as _channels
# aliases:
-from _xxsubinterpreters import (
+from _xxsubinterpreters import is_shareable
+from _xxinterpchannels import (
ChannelError, ChannelNotFoundError, ChannelEmptyError,
- is_shareable,
)
@@ -102,7 +103,7 @@ def create_channel():
The channel may be used to pass data safely between interpreters.
"""
- cid = _interpreters.channel_create()
+ cid = _channels.create()
recv, send = RecvChannel(cid), SendChannel(cid)
return recv, send
@@ -110,14 +111,14 @@ def create_channel():
def list_all_channels():
"""Return a list of (recv, send) for all open channels."""
return [(RecvChannel(cid), SendChannel(cid))
- for cid in _interpreters.channel_list_all()]
+ for cid in _channels.list_all()]
class _ChannelEnd:
"""The base class for RecvChannel and SendChannel."""
def __init__(self, id):
- if not isinstance(id, (int, _interpreters.ChannelID)):
+ if not isinstance(id, (int, _channels.ChannelID)):
raise TypeError(f'id must be an int, got {id!r}')
self._id = id
@@ -152,10 +153,10 @@ class RecvChannel(_ChannelEnd):
This blocks until an object has been sent, if none have been
sent already.
"""
- obj = _interpreters.channel_recv(self._id, _sentinel)
+ obj = _channels.recv(self._id, _sentinel)
while obj is _sentinel:
time.sleep(_delay)
- obj = _interpreters.channel_recv(self._id, _sentinel)
+ obj = _channels.recv(self._id, _sentinel)
return obj
def recv_nowait(self, default=_NOT_SET):
@@ -166,9 +167,9 @@ class RecvChannel(_ChannelEnd):
is the same as recv().
"""
if default is _NOT_SET:
- return _interpreters.channel_recv(self._id)
+ return _channels.recv(self._id)
else:
- return _interpreters.channel_recv(self._id, default)
+ return _channels.recv(self._id, default)
class SendChannel(_ChannelEnd):
@@ -179,7 +180,7 @@ class SendChannel(_ChannelEnd):
This blocks until the object is received.
"""
- _interpreters.channel_send(self._id, obj)
+ _channels.send(self._id, obj)
# XXX We are missing a low-level channel_send_wait().
# See bpo-32604 and gh-19829.
# Until that shows up we fake it:
@@ -194,4 +195,4 @@ class SendChannel(_ChannelEnd):
# XXX Note that at the moment channel_send() only ever returns
# None. This should be fixed when channel_send_wait() is added.
# See bpo-32604 and gh-19829.
- return _interpreters.channel_send(self._id, obj)
+ return _channels.send(self._id, obj)