Content-Length: 374540 | pFad | http://github.com/python/cpython/pull/115566/commits/cc4dc35216efeac179046b0c29831e6de69e18f2

84 gh-76785: Update test.support.interpreters to Align With PEP 734 by ericsnowcurrently · Pull Request #115566 · python/cpython · GitHub
Skip to content

gh-76785: Update test.support.interpreters to Align With PEP 734 #115566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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 Queue.
  • Loading branch information
ericsnowcurrently committed Feb 27, 2024
commit cc4dc35216efeac179046b0c29831e6de69e18f2
11 changes: 8 additions & 3 deletions Lib/test/support/interpreters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,27 @@
'Interpreter',
'InterpreterError', 'InterpreterNotFoundError', 'ExecFailure',
'NotShareableError',
'create_shared_queue', 'SharedQueue', 'QueueEmpty', 'QueueFull',
'create_shared_queue', 'create_queue',
'SharedQueue', 'Queue',
'QueueEmpty', 'QueueFull',
]


_queuemod = None

def __getattr__(name):
if name in ('QueueEmpty', 'QueueFull',
'SharedQueue', 'create_shared_queue'):
'SharedQueue', 'create_shared_queue',
'Queue', 'create_queue'):
global QueueEmpty, QueueFull
global create_shared_queue, SharedQueue
global create_queue, Queue
ns = globals()
from .queues import (
QueueEmpty, QueueFull,
create_shared as create_shared_queue,
SharedQueue,
create as create_queue,
SharedQueue, Queue,
)
return ns[name]
else:
Expand Down
40 changes: 35 additions & 5 deletions Lib/test/support/interpreters/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
)

__all__ = [
'create_shared', 'list_all',
'SharedQueue',
'create_shared', 'create', 'list_all',
'SharedQueue', 'Queue',
'QueueError', 'QueueNotFoundError', 'QueueEmpty', 'QueueFull',
]

Expand All @@ -35,15 +35,29 @@ def create_shared(maxsize=0):
"""Return a new cross-interpreter queue.

The queue may be used to pass data safely between interpreters.
Only "shareable" objects put into the queue. The data is handled
with maximum efficiency.
"""
qid = _queues.create(maxsize)
qid = _queues.create(maxsize, sharedonly=True)
return SharedQueue(qid)


def create(maxsize=0):
"""Return a new cross-interpreter queue.

The queue may be used to pass data safely between interpreters.
Any object may be put into the queue. Each is serialized, and thus
copied. This approach is not as efficient as queues made with
create_shared().
"""
qid = _queues.create(maxsize, sharedonly=False)
return Queue(qid)


def list_all():
"""Return a list of all open queues."""
return [SharedQueue(qid)
for qid in _queues.list_all()]
return [SharedQueue(qid) if sharedonly else Queue(qid)
for qid, sharedonly in _queues.list_all()]



Expand Down Expand Up @@ -109,6 +123,8 @@ def put(self, obj, timeout=None, *,
):
"""Add the object to the queue.

The object must be "shareable".

This blocks while the queue is full.
"""
if timeout is not None:
Expand Down Expand Up @@ -169,4 +185,18 @@ def get_nowait(self):
raise # re-raise


class Queue(SharedQueue):
"""A cross-interpreter queue."""

def put(self, obj, timeout=None):
"""Add the object to the queue.

All objects are supported.

This blocks while the queue is full.
"""
super().put(obj, timeout)


_queues._register_queue_type(SharedQueue)
_queues._register_queue_type(Queue)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/115566/commits/cc4dc35216efeac179046b0c29831e6de69e18f2

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy