text
stringlengths
0
20k
# Copyright 2024 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, L...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from .base import BaseInf...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, L...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Litera...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, L...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Option...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Litera...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, L...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, L...
# This file is auto-generated by `utils/generate_inference_types.py`. # Do not modify it manually. # # ruff: noqa: F401 from .audio_classification import ( AudioClassificationInput, AudioClassificationOutputElement, AudioClassificationOutputTransform, AudioClassificationParameters, ) from .audio_to_aud...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, L...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Litera...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, L...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Litera...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
# Inference code generated from the JSON schema spec in @huggingface/tasks. # # See: # - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts # - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks. from typing import Any, O...
from ._common import BaseConversationalTask class CerebrasConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider="cerebras", base_url="https://api.cerebras.ai")
import base64 from abc import ABC from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from huggingface_hub.inference._providers._common import ( BaseConversationalTask, BaseTextGenerationTa...
from ._common import BaseConversationalTask class GroqConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider="groq", base_url="https://api.groq.com") def _prepare_route(self, mapped_model: str, api_key: str) -> str: return "/openai/v1/chat/completions"
from ._common import BaseConversationalTask _PROVIDER = "clarifai" _BASE_URL = "https://api.clarifai.com" class ClarifaiConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider=_PROVIDER, base_url=_BASE_URL) def _prepare_route(self, mapped_model: str, api_key: str) ...
from typing import Any, Optional from huggingface_hub.hf_api import InferenceProviderMapping from ._common import BaseConversationalTask class FireworksAIConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider="fireworks-ai", base_url="https://api.fireworks.ai") de...
import base64 from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from ._common import BaseConversationalTask, TaskProviderHelper, filter_none class NscaleConversationalTask(BaseConversationalTa...
from ._common import BaseConversationalTask class PublicAIConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider="publicai", base_url="https://api.publicai.co")
from typing import Any, Optional from huggingface_hub.hf_api import InferenceProviderMapping from ._common import BaseConversationalTask _PROVIDER = "cohere" _BASE_URL = "https://api.cohere.com" class CohereConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider=_PROV...
from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from huggingface_hub.inference._providers._common import BaseConversationalTask, TaskProviderHelper, filter_none class SambanovaConversationalT...
import json from functools import lru_cache from pathlib import Path from typing import Any, Optional, Union from urllib.parse import urlparse, urlunparse from huggingface_hub import constants from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import ( MimeBytes, ...
from typing import Optional from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._providers._common import BaseConversationalTask class OpenAIConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider="openai", base_url="https://api.ope...
from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from ._common import BaseConversationalTask, BaseTextGenerationTask, filter_none _PROVIDER = "featherless-ai" _BASE_URL = "https://api.feather...
from typing import Literal, Optional, Union from huggingface_hub.inference._providers.featherless_ai import ( FeatherlessConversationalTask, FeatherlessTextGenerationTask, ) from huggingface_hub.utils import logging from ._common import AutoRouterConversationalTask, TaskProviderHelper, _fetch_inference_provid...
import base64 from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from huggingface_hub.inference._providers._common import BaseConversationalTask, TaskProviderHelper, filter_none class Hyperbolic...
import time from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from huggingface_hub.inference._providers._common import TaskProviderHelper, filter_none from huggingface_hub.utils import logging fr...
import base64 import time from abc import ABC from typing import Any, Optional, Union from urllib.parse import urlparse from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from huggingface_hub.inference._providers._common import TaskProv...
from typing import Any, Dict, Optional, Union from huggingface_hub.inference._common import RequestParameters, _as_dict from ._common import BaseConversationalTask, InferenceProviderMapping, TaskProviderHelper, filter_none class ScalewayConversationalTask(BaseConversationalTask): def __init__(self): sup...
from typing import Any, Dict from huggingface_hub.inference._providers._common import BaseConversationalTask class ZaiConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider="zai-org", base_url="https://api.z.ai") def _prepare_headers(self, headers: Dict, api_key: s...
import base64 from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from huggingface_hub.inference._providers._common import ( BaseConversationalTask, BaseTextGenerationTask, TaskProvider...
from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict, _as_url from huggingface_hub.inference._providers._common import TaskProviderHelper, filter_none from huggingface_hub.utils import get_session ...
import base64 import time from abc import ABC from typing import Any, Optional, Union from urllib.parse import urlparse from huggingface_hub import constants from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict, _as_url from huggingface_h...
from typing import Any, Optional, Union from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import RequestParameters, _as_dict from huggingface_hub.inference._providers._common import ( BaseConversationalTask, BaseTextGenerationTask, TaskProviderHelper, fi...
from huggingface_hub.inference._providers._common import BaseConversationalTask _PROVIDER = "ovhcloud" _BASE_URL = "https://oai.endpoints.kepler.ai.cloud.ovh.net" class OVHcloudConversationalTask(BaseConversationalTask): def __init__(self): super().__init__(provider=_PROVIDER, base_url=_BASE_URL)
from functools import lru_cache from typing import Any, Optional, Union, overload from huggingface_hub import constants from huggingface_hub.hf_api import InferenceProviderMapping from huggingface_hub.inference._common import MimeBytes, RequestParameters from huggingface_hub.inference._generated.types.chat_completion ...
# coding=utf-8 # Copyright 2023-present, the HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
""" An implementation of `urlparse` that provides URL validation and normalization as described by RFC3986. We rely on this implementation rather than the one in Python's stdlib, because: * It provides more complete URL validation. * It properly differentiates between an empty querystring and an absent querystring, ...
from __future__ import annotations from enum import IntEnum __all__ = ["codes"] class codes(IntEnum): """HTTP status codes and reason phrases Status codes from the following RFCs are all observed: * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616 * RFC 6585: Additional HTT...
from __future__ import annotations import functools import json import sys import typing import click import pygments.lexers import pygments.util import rich.console import rich.markup import rich.progress import rich.syntax import rich.table from ._client import Client from ._exceptions import RequestError from ._m...
from __future__ import annotations import inspect import warnings from json import dumps as json_dumps from typing import ( Any, AsyncIterable, AsyncIterator, Iterable, Iterator, Mapping, ) from urllib.parse import urlencode from ._exceptions import StreamClosed, StreamConsumed from ._multipar...
__title__ = "httpx" __description__ = "A next generation HTTP client, for Python 3." __version__ = "0.28.1"
from __future__ import annotations import os import typing from ._models import Headers from ._types import CertTypes, HeaderTypes, TimeoutTypes from ._urls import URL if typing.TYPE_CHECKING: import ssl # pragma: no cover __all__ = ["Limits", "Proxy", "Timeout", "create_ssl_context"] class UnsetType: pa...
""" Type definitions for type checking purposes. """ from http.cookiejar import CookieJar from typing import ( IO, TYPE_CHECKING, Any, AsyncIterable, AsyncIterator, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Sequence, Tuple, Union, ) if TYP...
from .__version__ import __description__, __title__, __version__ from ._api import * from ._auth import * from ._client import * from ._config import * from ._content import * from ._exceptions import * from ._models import * from ._status_codes import * from ._transports import * from ._types import * from ._urls impo...
from __future__ import annotations import io import mimetypes import os import re import typing from pathlib import Path from ._types import ( AsyncByteStream, FileContent, FileTypes, RequestData, RequestFiles, SyncByteStream, ) from ._utils import ( peek_filelike_length, primitive_val...
from __future__ import annotations import io import itertools import sys import typing from .._models import Request, Response from .._types import SyncByteStream from .base import BaseTransport if typing.TYPE_CHECKING: from _typeshed import OptExcInfo # pragma: no cover from _typeshed.wsgi import WSGIAppli...
from __future__ import annotations import typing from types import TracebackType from .._models import Request, Response T = typing.TypeVar("T", bound="BaseTransport") A = typing.TypeVar("A", bound="AsyncBaseTransport") __all__ = ["AsyncBaseTransport", "BaseTransport"] class BaseTransport: def __enter__(self:...
from __future__ import annotations import typing from .._models import Request, Response from .._types import AsyncByteStream from .base import AsyncBaseTransport if typing.TYPE_CHECKING: # pragma: no cover import asyncio import trio Event = typing.Union[asyncio.Event, trio.Event] _Message = typing....
""" Custom transports, with nicely configured defaults. The following additional keyword arguments are currently supported by httpcore... * uds: str * local_address: str * retries: int Example usages... # Disable HTTP/2 on a single specific domain. mounts = { "all://": httpx.HTTPTransport(http2=True), "all:...
from .asgi import * from .base import * from .default import * from .mock import * from .wsgi import * __all__ = [ "ASGITransport", "AsyncBaseTransport", "BaseTransport", "AsyncHTTPTransport", "HTTPTransport", "MockTransport", "WSGITransport", ]
from __future__ import annotations import typing from .._models import Request, Response from .base import AsyncBaseTransport, BaseTransport SyncHandler = typing.Callable[[Request], Response] AsyncHandler = typing.Callable[[Request], typing.Coroutine[None, None, Response]] __all__ = ["MockTransport"] class MockT...
from __future__ import annotations import ipaddress import os import re import typing from urllib.request import getproxies from ._types import PrimitiveData if typing.TYPE_CHECKING: # pragma: no cover from ._urls import URL def primitive_value_to_str(value: PrimitiveData) -> str: """ Coerce a primiti...
from __future__ import annotations import hashlib import os import re import time import typing from base64 import b64encode from urllib.request import parse_http_list from ._exceptions import ProtocolError from ._models import Cookies, Request, Response from ._utils import to_bytes, to_str, unquote if typing.TYPE_C...
""" Our exception hierarchy: * HTTPError x RequestError + TransportError - TimeoutException · ConnectTimeout · ReadTimeout · WriteTimeout · PoolTimeout - NetworkError · ConnectError · ReadError · WriteError · CloseError - ProtocolE...
from __future__ import annotations import typing from contextlib import contextmanager from ._client import Client from ._config import DEFAULT_TIMEOUT_CONFIG from ._models import Response from ._types import ( AuthTypes, CookieTypes, HeaderTypes, ProxyTypes, QueryParamTypes, RequestContent, ...
""" Handlers for Content-Encoding. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding """ from __future__ import annotations import codecs import io import typing import zlib from ._exceptions import DecodingError # Brotli support is optional try: # The C bindings in `brotli` are r...
"""Utilities for working with paths.""" from collections.abc import Sequence from contextlib import suppress def normalize_path_segments(segments: Sequence[str]) -> list[str]: """Drop '.' and '..' from a sequence of str segments""" resolved_path: list[str] = [] for seg in segments: if seg == "....
"""Quoting and unquoting utilities for URL parts.""" from typing import Union from urllib.parse import quote from ._quoting import _Quoter, _Unquoter QUOTER = _Quoter(requote=False) REQUOTER = _Quoter() PATH_QUOTER = _Quoter(safe="@:", protected="/+", requote=False) PATH_REQUOTER = _Quoter(safe="@:", protected="/+")...
"""URL parsing utilities.""" import re import unicodedata from functools import lru_cache from typing import Union from urllib.parse import scheme_chars, uses_netloc from ._quoters import QUOTER, UNQUOTER_PLUS # Leading and trailing C0 control and space to be stripped per WHATWG spec. # == "".join([chr(i) for i in r...
from cpython.exc cimport PyErr_NoMemory from cpython.mem cimport PyMem_Free, PyMem_Malloc, PyMem_Realloc from cpython.unicode cimport ( PyUnicode_DATA, PyUnicode_DecodeASCII, PyUnicode_DecodeUTF8Stateful, PyUnicode_GET_LENGTH, PyUnicode_KIND, PyUnicode_READ, ) from libc.stdint cimport uint8_t, u...
from ._query import Query, QueryVariable, SimpleQuery from ._url import URL, cache_clear, cache_configure, cache_info __version__ = "1.22.0" __all__ = ( "URL", "SimpleQuery", "QueryVariable", "Query", "cache_clear", "cache_configure", "cache_info", )
"""Query string handling.""" import math from collections.abc import Iterable, Mapping, Sequence from typing import TYPE_CHECKING, Any, SupportsInt, Union, cast from multidict import istr from ._quoters import QUERY_PART_QUOTER, QUERY_QUOTER SimpleQuery = Union[str, SupportsInt, float] QueryVariable = Union[SimpleQ...
import codecs import re from string import ascii_letters, ascii_lowercase, digits from typing import Union, overload BASCII_LOWERCASE = ascii_lowercase.encode("ascii") BPCT_ALLOWED = {f"%{i:02X}".encode("ascii") for i in range(256)} GEN_DELIMS = ":/?#[]@" SUB_DELIMS_WITHOUT_QS = "!$'()*," SUB_DELIMS = SUB_DELIMS_WITHO...
import os import sys from typing import TYPE_CHECKING __all__ = ("_Quoter", "_Unquoter") NO_EXTENSIONS = bool(os.environ.get("YARL_NO_EXTENSIONS")) # type: bool if sys.implementation.name != "cpython": NO_EXTENSIONS = True if TYPE_CHECKING or NO_EXTENSIONS: from ._quoting_py import _Quoter, _Unquoter else...
# # We use a background thread for sharing fds on Unix, and for sharing sockets on # Windows. # # A client which wants to pickle a resource registers it with the resource # sharer and gets an identifier in return. The unpickling process will connect # to the resource sharer, sends the identifier and its pid, and then ...
#!/usr/bin/env python # # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) # Copyright (c) 2025 The Uncertainty Quantification Foundation. # License: 3-clause BSD. The full license text is available at: # - https://github.com/uqfoundation/multiprocess/blob/master/LICENSE ''' --------------------------------...
# # Analogue of `multiprocessing.connection` which uses queues instead of sockets # # multiprocessing/dummy/connection.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # __all__ = [ 'Client', 'Listener', 'Pipe' ] from queue import Queue families = [None] class Listener(ob...
# # Support for the API of the multiprocessing package using threads # # multiprocessing/dummy/__init__.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # __all__ = [ 'Process', 'current_process', 'active_children', 'freeze_support', 'Lock', 'RLock', 'Semaphore', 'Boun...
# # Module implementing queues # # multiprocessing/queues.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # __all__ = ['Queue', 'SimpleQueue', 'JoinableQueue'] import sys import os import threading import collections import time import types import weakref import errno from...
import io import os from .context import reduction, set_spawning_popen if not reduction.HAVE_SEND_HANDLE: raise ImportError('No support for sending fds between processes') from . import forkserver from . import popen_fork from . import spawn from . import util __all__ = ['Popen'] # # Wrapper for an fd used whil...
"""Provides shared memory for direct access across processes. The API of this package is currently provisional. Refer to the documentation for details. """ __all__ = [ 'SharedMemory', 'ShareableList' ] from functools import partial import mmap import os import errno import struct import secrets import types if os...
import errno import os import selectors import signal import socket import struct import sys import threading import warnings from . import connection from . import process from .context import reduction from . import resource_tracker from . import spawn from . import util __all__ = ['ensure_running', 'get_inherited_...
# # Module providing the `Process` class which emulates `threading.Thread` # # multiprocessing/process.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # __all__ = ['BaseProcess', 'current_process', 'active_children', 'parent_process'] # # Imports # import os impo...
# # Package analogous to 'threading.py' but using processes # # multiprocessing/__init__.py # # This package is intended to duplicate the functionality (and much of # the API) of threading.py but uses processes instead of threads. A # subpackage 'multiprocessing.dummy' has the same API but is a simple # wrapper for 't...
# # Module which supports allocation of ctypes objects from shared memory # # multiprocessing/sharedctypes.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # import ctypes import weakref from . import heap from . import get_context from .context import reduction, assert_spaw...
# # Module which deals with pickling of objects. # # multiprocessing/reduction.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # from abc import ABCMeta import copyreg import functools import io import os try: import dill as pickle except ImportError: import pickle im...
# # Code used to start processes when using the spawn or forkserver # start methods. # # multiprocessing/spawn.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # import os import sys import runpy import types from . import get_start_method, set_start_method from . import proc...
############################################################################### # Server process to keep track of unlinked resources (like shared memory # segments, semaphores etc.) and clean them. # # On Unix we run a server process which keeps track of unlinked # resources. The server ignores SIGINT and SIGTERM and r...
# # Module providing various facilities to other parts of the package # # multiprocessing/util.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # import os import itertools import sys import weakref import atexit import threading # we want threading to install it's ...
# # Module which supports allocation of memory from an mmap # # multiprocessing/heap.py # # Copyright (c) 2006-2008, R Oudkerk # Licensed to PSF under a Contributor Agreement. # import bisect from collections import defaultdict import mmap import os import sys import tempfile import threading from .context import red...
import os import msvcrt import signal import sys import _winapi from .context import reduction, get_spawning_popen, set_spawning_popen from . import spawn from . import util __all__ = ['Popen'] # # # # Exit code used by Popen.terminate() TERMINATE = 0x10000 WINEXE = (sys.platform == 'win32' and getattr(sys, 'frozen...
import os import sys import threading from . import process from . import reduction __all__ = () # # Exceptions # class ProcessError(Exception): pass class BufferTooShort(ProcessError): pass class TimeoutError(ProcessError): pass class AuthenticationError(ProcessError): pass # # Base type for co...
import os import signal from . import util __all__ = ['Popen'] # # Start child process using fork # class Popen(object): method = 'fork' def __init__(self, process_obj): util._flush_std_streams() self.returncode = None self.finalizer = None self._launch(process_obj) def...
# tests __main__ module handling in multiprocessing from test import support from test.support import import_helper # Skip tests if _multiprocessing wasn't built. import_helper.import_module('_multiprocessing') import importlib import importlib.machinery import unittest import sys import os import os.path import py_co...
import multiprocessing multiprocessing.Lock() def f(): print("ok") if __name__ == "__main__": ctx = multiprocessing.get_context("forkserver") modname = "multiprocess.tests.mp_preload" # Make sure it's importable __import__(modname) ctx.set_forkserver_preload([modname]) proc = ctx.Proces...
import unittest from multiprocess.tests import install_tests_in_module_dict install_tests_in_module_dict(globals(), 'forkserver', only_type="processes") if __name__ == '__main__': unittest.main()
import unittest from multiprocess.tests import install_tests_in_module_dict install_tests_in_module_dict(globals(), 'forkserver', only_type="threads") if __name__ == '__main__': unittest.main()