-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add concurrent.interpreters
stubs for 3.14.0b3
#14307
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
Open
brianschubert
wants to merge
1
commit into
python:main
Choose a base branch
from
brianschubert:gh-14303-stdlib-3-14-0b3-concurrent-interpreters
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import threading | ||
import types | ||
from collections.abc import Callable, Mapping | ||
from typing import Literal, TypeVar | ||
from typing_extensions import ParamSpec, Self | ||
|
||
from _interpreters import ( | ||
InterpreterError as InterpreterError, | ||
InterpreterNotFoundError as InterpreterNotFoundError, | ||
NotShareableError as NotShareableError, | ||
_Whence, | ||
is_shareable as is_shareable, | ||
) | ||
|
||
from ._queues import Queue as Queue, QueueEmpty as QueueEmpty, QueueFull as QueueFull, create as create_queue | ||
|
||
__all__ = [ | ||
"ExecutionFailed", | ||
"Interpreter", | ||
"InterpreterError", | ||
"InterpreterNotFoundError", | ||
"NotShareableError", | ||
"Queue", | ||
"QueueEmpty", | ||
"QueueFull", | ||
"create", | ||
"create_queue", | ||
"get_current", | ||
"get_main", | ||
"is_shareable", | ||
"list_all", | ||
] | ||
|
||
_R = TypeVar("_R") | ||
_P = ParamSpec("_P") | ||
|
||
class ExecutionFailed(InterpreterError): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what to make of the pyright errors here and in
|
||
excinfo: types.SimpleNamespace | ||
|
||
def __init__(self, excinfo: types.SimpleNamespace) -> None: ... | ||
|
||
def create() -> Interpreter: ... | ||
def list_all() -> list[Interpreter]: ... | ||
def get_current() -> Interpreter: ... | ||
def get_main() -> Interpreter: ... | ||
|
||
class Interpreter: | ||
def __new__(cls, id: int, /, _whence: _Whence | None = None, _ownsref: bool | None = None) -> Self: ... | ||
def __getnewargs__(self) -> tuple[int]: ... | ||
def __hash__(self) -> int: ... | ||
def __del__(self) -> None: ... | ||
@property | ||
def id(self) -> int: ... | ||
@property | ||
def whence( | ||
self, | ||
) -> Literal["unknown", "runtime init", "legacy C-API", "C-API", "cross-interpreter C-API", "_interpreters module"]: ... | ||
def is_running(self) -> bool: ... | ||
def close(self) -> None: ... | ||
def prepare_main(self, ns: Mapping[str, object] | None = None, /, **kwargs: object) -> None: ... | ||
def exec(self, code: str | types.CodeType | Callable[[], object], /) -> None: ... | ||
def call(self, callable: Callable[_P, _R], /, *args: _P.args, **kwargs: _P.kwargs) -> _R: ... | ||
def call_in_thread(self, callable: Callable[_P, object], /, *args: _P.args, **kwargs: _P.kwargs) -> threading.Thread: ... |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from collections.abc import Callable | ||
from typing import Never, NewType | ||
from typing_extensions import Self, TypeAlias | ||
|
||
from _interpqueues import _UnboundOp | ||
|
||
class ItemInterpreterDestroyed(Exception): ... | ||
|
||
# Actually a descriptor that behaves similarly to classmethod but prevents | ||
# access from instances. | ||
classonly = classmethod | ||
|
||
class UnboundItem: | ||
def __new__(cls) -> Never: ... | ||
@classonly | ||
def singleton(cls, kind: str, module: str, name: str = "UNBOUND") -> Self: ... | ||
|
||
_UnboundErrorType = NewType("_UnboundErrorType", object) | ||
_UnboundRemoveType = NewType("_UnboundRemoveType", object) | ||
|
||
UNBOUND_ERROR: _UnboundErrorType | ||
UNBOUND_REMOVE: _UnboundRemoveType | ||
UNBOUND: UnboundItem # analogous to UNBOUND_REPLACE in C | ||
_AnyUnbound: TypeAlias = _UnboundErrorType | _UnboundRemoveType | UnboundItem | ||
|
||
def serialize_unbound(unbound: _AnyUnbound) -> tuple[_UnboundOp]: ... | ||
def resolve_unbound(flag: _UnboundOp, exctype_destroyed: Callable[[str], BaseException]) -> UnboundItem: ... |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import queue | ||
from typing import SupportsIndex | ||
from typing_extensions import Self | ||
|
||
from _interpqueues import QueueError as QueueError, QueueNotFoundError as QueueNotFoundError | ||
|
||
from . import _crossinterp | ||
from ._crossinterp import UNBOUND_ERROR as UNBOUND_ERROR, UNBOUND_REMOVE as UNBOUND_REMOVE | ||
|
||
__all__ = [ | ||
"UNBOUND", | ||
"UNBOUND_ERROR", | ||
"UNBOUND_REMOVE", | ||
"ItemInterpreterDestroyed", | ||
"Queue", | ||
"QueueEmpty", | ||
"QueueError", | ||
"QueueFull", | ||
"QueueNotFoundError", | ||
"create", | ||
"list_all", | ||
] | ||
|
||
class QueueEmpty(QueueError, queue.Empty): ... | ||
class QueueFull(QueueError, queue.Full): ... | ||
class ItemInterpreterDestroyed(QueueError, _crossinterp.ItemInterpreterDestroyed): ... | ||
|
||
UNBOUND: _crossinterp.UnboundItem | ||
|
||
def create(maxsize: int = 0, *, unbounditems: _crossinterp._AnyUnbound = ...) -> Queue: ... | ||
def list_all() -> list[Queue]: ... | ||
|
||
class Queue: | ||
def __new__(cls, id: int, /) -> Self: ... | ||
def __del__(self) -> None: ... | ||
def __hash__(self) -> int: ... | ||
def __getnewargs__(self) -> tuple[int]: ... | ||
@property | ||
def id(self) -> int: ... | ||
@property | ||
def unbounditems(self) -> _crossinterp._AnyUnbound: ... | ||
@property | ||
def maxsize(self) -> int: ... | ||
def empty(self) -> bool: ... | ||
def full(self) -> bool: ... | ||
def qsize(self) -> int: ... | ||
def put( | ||
self, | ||
obj: object, | ||
timeout: SupportsIndex | None = None, | ||
*, | ||
unbounditems: _crossinterp._AnyUnbound | None = None, | ||
_delay: float = ..., | ||
) -> None: ... | ||
def put_nowait(self, obj: object, *, unbounditems: _crossinterp._AnyUnbound | None = None) -> None: ... | ||
def get(self, timeout: SupportsIndex | None = None, *, _delay: float = ...) -> object: ... | ||
def get_nowait(self) -> object: ... |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: there's a discussion about whether this module will ultimately be named
concurrent.interpreters
orinterpreters
: https://discuss.python.org/t/interpreters-vs-concurrent-interpreters/95980. Does it make sense to add these here for now if there's a chance the name will change?