-
-
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
Merged
srittau
merged 8 commits into
python:main
from
brianschubert:gh-14303-stdlib-3-14-0b3-concurrent-interpreters
Jul 21, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d030d7d
Add `concurrent.interpreters` stubs for 3.14.0b3
brianschubert bd9ba37
Merge branch 'main'
brianschubert 9c6d9ab
Merge branch 'main' into gh-14303-stdlib-3-14-0b3-concurrent-interpre…
srittau 519a6b8
Merge branch 'main'
brianschubert d4175cb
Fix pyright checks for Python <3.13
brianschubert 6a68a3d
Update pickling methods for v3.14.0b4
brianschubert 88a9e17
Address review comments, tidy
brianschubert 6144947
Add comment for Any in prepare_main kwargs
brianschubert 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,68 @@ | ||
import sys | ||
import threading | ||
import types | ||
from collections.abc import Callable | ||
from typing import Any, Literal, TypeVar | ||
from typing_extensions import ParamSpec, Self | ||
|
||
if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 | ||
from _interpreters import ( | ||
InterpreterError as InterpreterError, | ||
InterpreterNotFoundError as InterpreterNotFoundError, | ||
NotShareableError as NotShareableError, | ||
_SharedDict, | ||
_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): | ||
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 __reduce__(self) -> tuple[type[Self], 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: _SharedDict | None = None, /, **kwargs: Any | ||
) -> None: ... # kwargs has same value restrictions as _SharedDict | ||
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,29 @@ | ||
import sys | ||
from collections.abc import Callable | ||
from typing import Final, NewType | ||
from typing_extensions import Never, Self, TypeAlias | ||
|
||
if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 | ||
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: ... | ||
|
||
# Sentinel types and alias that don't exist at runtime. | ||
_UnboundErrorType = NewType("_UnboundErrorType", object) | ||
_UnboundRemoveType = NewType("_UnboundRemoveType", object) | ||
brianschubert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_AnyUnbound: TypeAlias = _UnboundErrorType | _UnboundRemoveType | UnboundItem | ||
brianschubert marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
UNBOUND_ERROR: Final[_UnboundErrorType] | ||
UNBOUND_REMOVE: Final[_UnboundRemoveType] | ||
UNBOUND: Final[UnboundItem] # analogous to UNBOUND_REPLACE in C | ||
|
||
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,58 @@ | ||
import queue | ||
import sys | ||
from typing import Final, SupportsIndex | ||
from typing_extensions import Self | ||
|
||
if sys.version_info >= (3, 13): # needed to satisfy pyright checks for Python <3.13 | ||
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, UnboundItem, _AnyUnbound | ||
|
||
__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: Final[UnboundItem] | ||
|
||
def create(maxsize: int = 0, *, unbounditems: _AnyUnbound = ...) -> Queue: ... | ||
def list_all() -> list[Queue]: ... | ||
|
||
class Queue: | ||
def __new__(cls, id: int, /) -> Self: ... | ||
def __del__(self) -> None: ... | ||
def __hash__(self) -> int: ... | ||
def __reduce__(self) -> tuple[type[Self], int]: ... | ||
@property | ||
def id(self) -> int: ... | ||
@property | ||
def unbounditems(self) -> _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: _AnyUnbound | None = None, | ||
_delay: float = ..., | ||
) -> None: ... | ||
def put_nowait(self, obj: object, *, unbounditems: _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.