HEX
Server: Apache
System: Linux vmi318001.contaboserver.net 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User: boxelikax (1004)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: /home/boxelikax/public_html/demoltec.com/concurrent.tar
__init__.py000064400000000046152402271140006653 0ustar00# This directory is a Python package.
futures/_base.py000064400000054461152402271140007674 0ustar00# Copyright 2009 Brian Quinlan. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

__author__ = 'Brian Quinlan (brian@sweetapp.com)'

import collections
import logging
import threading
import time
import types

FIRST_COMPLETED = 'FIRST_COMPLETED'
FIRST_EXCEPTION = 'FIRST_EXCEPTION'
ALL_COMPLETED = 'ALL_COMPLETED'
_AS_COMPLETED = '_AS_COMPLETED'

# Possible future states (for internal use by the futures package).
PENDING = 'PENDING'
RUNNING = 'RUNNING'
# The future was cancelled by the user...
CANCELLED = 'CANCELLED'
# ...and _Waiter.add_cancelled() was called by a worker.
CANCELLED_AND_NOTIFIED = 'CANCELLED_AND_NOTIFIED'
FINISHED = 'FINISHED'

_FUTURE_STATES = [
    PENDING,
    RUNNING,
    CANCELLED,
    CANCELLED_AND_NOTIFIED,
    FINISHED
]

_STATE_TO_DESCRIPTION_MAP = {
    PENDING: "pending",
    RUNNING: "running",
    CANCELLED: "cancelled",
    CANCELLED_AND_NOTIFIED: "cancelled",
    FINISHED: "finished"
}

# Logger for internal use by the futures package.
LOGGER = logging.getLogger("concurrent.futures")

class Error(Exception):
    """Base class for all future-related exceptions."""
    pass

class CancelledError(Error):
    """The Future was cancelled."""
    pass

TimeoutError = TimeoutError  # make local alias for the standard exception

class InvalidStateError(Error):
    """The operation is not allowed in this state."""
    pass

class _Waiter(object):
    """Provides the event that wait() and as_completed() block on."""
    def __init__(self):
        self.event = threading.Event()
        self.finished_futures = []

    def add_result(self, future):
        self.finished_futures.append(future)

    def add_exception(self, future):
        self.finished_futures.append(future)

    def add_cancelled(self, future):
        self.finished_futures.append(future)

class _AsCompletedWaiter(_Waiter):
    """Used by as_completed()."""

    def __init__(self):
        super(_AsCompletedWaiter, self).__init__()
        self.lock = threading.Lock()

    def add_result(self, future):
        with self.lock:
            super(_AsCompletedWaiter, self).add_result(future)
            self.event.set()

    def add_exception(self, future):
        with self.lock:
            super(_AsCompletedWaiter, self).add_exception(future)
            self.event.set()

    def add_cancelled(self, future):
        with self.lock:
            super(_AsCompletedWaiter, self).add_cancelled(future)
            self.event.set()

class _FirstCompletedWaiter(_Waiter):
    """Used by wait(return_when=FIRST_COMPLETED)."""

    def add_result(self, future):
        super().add_result(future)
        self.event.set()

    def add_exception(self, future):
        super().add_exception(future)
        self.event.set()

    def add_cancelled(self, future):
        super().add_cancelled(future)
        self.event.set()

class _AllCompletedWaiter(_Waiter):
    """Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED)."""

    def __init__(self, num_pending_calls, stop_on_exception):
        self.num_pending_calls = num_pending_calls
        self.stop_on_exception = stop_on_exception
        self.lock = threading.Lock()
        super().__init__()

    def _decrement_pending_calls(self):
        with self.lock:
            self.num_pending_calls -= 1
            if not self.num_pending_calls:
                self.event.set()

    def add_result(self, future):
        super().add_result(future)
        self._decrement_pending_calls()

    def add_exception(self, future):
        super().add_exception(future)
        if self.stop_on_exception:
            self.event.set()
        else:
            self._decrement_pending_calls()

    def add_cancelled(self, future):
        super().add_cancelled(future)
        self._decrement_pending_calls()

class _AcquireFutures(object):
    """A context manager that does an ordered acquire of Future conditions."""

    def __init__(self, futures):
        self.futures = sorted(futures, key=id)

    def __enter__(self):
        for future in self.futures:
            future._condition.acquire()

    def __exit__(self, *args):
        for future in self.futures:
            future._condition.release()

def _create_and_install_waiters(fs, return_when):
    if return_when == _AS_COMPLETED:
        waiter = _AsCompletedWaiter()
    elif return_when == FIRST_COMPLETED:
        waiter = _FirstCompletedWaiter()
    else:
        pending_count = sum(
                f._state not in [CANCELLED_AND_NOTIFIED, FINISHED] for f in fs)

        if return_when == FIRST_EXCEPTION:
            waiter = _AllCompletedWaiter(pending_count, stop_on_exception=True)
        elif return_when == ALL_COMPLETED:
            waiter = _AllCompletedWaiter(pending_count, stop_on_exception=False)
        else:
            raise ValueError("Invalid return condition: %r" % return_when)

    for f in fs:
        f._waiters.append(waiter)

    return waiter


def _yield_finished_futures(fs, waiter, ref_collect):
    """
    Iterate on the list *fs*, yielding finished futures one by one in
    reverse order.
    Before yielding a future, *waiter* is removed from its waiters
    and the future is removed from each set in the collection of sets
    *ref_collect*.

    The aim of this function is to avoid keeping stale references after
    the future is yielded and before the iterator resumes.
    """
    while fs:
        f = fs[-1]
        for futures_set in ref_collect:
            futures_set.remove(f)
        with f._condition:
            f._waiters.remove(waiter)
        del f
        # Careful not to keep a reference to the popped value
        yield fs.pop()


def as_completed(fs, timeout=None):
    """An iterator over the given futures that yields each as it completes.

    Args:
        fs: The sequence of Futures (possibly created by different Executors) to
            iterate over.
        timeout: The maximum number of seconds to wait. If None, then there
            is no limit on the wait time.

    Returns:
        An iterator that yields the given Futures as they complete (finished or
        cancelled). If any given Futures are duplicated, they will be returned
        once.

    Raises:
        TimeoutError: If the entire result iterator could not be generated
            before the given timeout.
    """
    if timeout is not None:
        end_time = timeout + time.monotonic()

    fs = set(fs)
    total_futures = len(fs)
    with _AcquireFutures(fs):
        finished = set(
                f for f in fs
                if f._state in [CANCELLED_AND_NOTIFIED, FINISHED])
        pending = fs - finished
        waiter = _create_and_install_waiters(fs, _AS_COMPLETED)
    finished = list(finished)
    try:
        yield from _yield_finished_futures(finished, waiter,
                                           ref_collect=(fs,))

        while pending:
            if timeout is None:
                wait_timeout = None
            else:
                wait_timeout = end_time - time.monotonic()
                if wait_timeout < 0:
                    raise TimeoutError(
                            '%d (of %d) futures unfinished' % (
                            len(pending), total_futures))

            waiter.event.wait(wait_timeout)

            with waiter.lock:
                finished = waiter.finished_futures
                waiter.finished_futures = []
                waiter.event.clear()

            # reverse to keep finishing order
            finished.reverse()
            yield from _yield_finished_futures(finished, waiter,
                                               ref_collect=(fs, pending))

    finally:
        # Remove waiter from unfinished futures
        for f in fs:
            with f._condition:
                f._waiters.remove(waiter)

DoneAndNotDoneFutures = collections.namedtuple(
        'DoneAndNotDoneFutures', 'done not_done')
def wait(fs, timeout=None, return_when=ALL_COMPLETED):
    """Wait for the futures in the given sequence to complete.

    Args:
        fs: The sequence of Futures (possibly created by different Executors) to
            wait upon.
        timeout: The maximum number of seconds to wait. If None, then there
            is no limit on the wait time.
        return_when: Indicates when this function should return. The options
            are:

            FIRST_COMPLETED - Return when any future finishes or is
                              cancelled.
            FIRST_EXCEPTION - Return when any future finishes by raising an
                              exception. If no future raises an exception
                              then it is equivalent to ALL_COMPLETED.
            ALL_COMPLETED -   Return when all futures finish or are cancelled.

    Returns:
        A named 2-tuple of sets. The first set, named 'done', contains the
        futures that completed (is finished or cancelled) before the wait
        completed. The second set, named 'not_done', contains uncompleted
        futures. Duplicate futures given to *fs* are removed and will be
        returned only once.
    """
    fs = set(fs)
    with _AcquireFutures(fs):
        done = {f for f in fs
                   if f._state in [CANCELLED_AND_NOTIFIED, FINISHED]}
        not_done = fs - done
        if (return_when == FIRST_COMPLETED) and done:
            return DoneAndNotDoneFutures(done, not_done)
        elif (return_when == FIRST_EXCEPTION) and done:
            if any(f for f in done
                   if not f.cancelled() and f.exception() is not None):
                return DoneAndNotDoneFutures(done, not_done)

        if len(done) == len(fs):
            return DoneAndNotDoneFutures(done, not_done)

        waiter = _create_and_install_waiters(fs, return_when)

    waiter.event.wait(timeout)
    for f in fs:
        with f._condition:
            f._waiters.remove(waiter)

    done.update(waiter.finished_futures)
    return DoneAndNotDoneFutures(done, fs - done)


def _result_or_cancel(fut, timeout=None):
    try:
        try:
            return fut.result(timeout)
        finally:
            fut.cancel()
    finally:
        # Break a reference cycle with the exception in self._exception
        del fut


class Future(object):
    """Represents the result of an asynchronous computation."""

    def __init__(self):
        """Initializes the future. Should not be called by clients."""
        self._condition = threading.Condition()
        self._state = PENDING
        self._result = None
        self._exception = None
        self._waiters = []
        self._done_callbacks = []

    def _invoke_callbacks(self):
        for callback in self._done_callbacks:
            try:
                callback(self)
            except Exception:
                LOGGER.exception('exception calling callback for %r', self)

    def __repr__(self):
        with self._condition:
            if self._state == FINISHED:
                if self._exception:
                    return '<%s at %#x state=%s raised %s>' % (
                        self.__class__.__name__,
                        id(self),
                        _STATE_TO_DESCRIPTION_MAP[self._state],
                        self._exception.__class__.__name__)
                else:
                    return '<%s at %#x state=%s returned %s>' % (
                        self.__class__.__name__,
                        id(self),
                        _STATE_TO_DESCRIPTION_MAP[self._state],
                        self._result.__class__.__name__)
            return '<%s at %#x state=%s>' % (
                    self.__class__.__name__,
                    id(self),
                   _STATE_TO_DESCRIPTION_MAP[self._state])

    def cancel(self):
        """Cancel the future if possible.

        Returns True if the future was cancelled, False otherwise. A future
        cannot be cancelled if it is running or has already completed.
        """
        with self._condition:
            if self._state in [RUNNING, FINISHED]:
                return False

            if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
                return True

            self._state = CANCELLED
            self._condition.notify_all()

        self._invoke_callbacks()
        return True

    def cancelled(self):
        """Return True if the future was cancelled."""
        with self._condition:
            return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]

    def running(self):
        """Return True if the future is currently executing."""
        with self._condition:
            return self._state == RUNNING

    def done(self):
        """Return True if the future was cancelled or finished executing."""
        with self._condition:
            return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]

    def __get_result(self):
        if self._exception:
            try:
                raise self._exception
            finally:
                # Break a reference cycle with the exception in self._exception
                self = None
        else:
            return self._result

    def add_done_callback(self, fn):
        """Attaches a callable that will be called when the future finishes.

        Args:
            fn: A callable that will be called with this future as its only
                argument when the future completes or is cancelled. The callable
                will always be called by a thread in the same process in which
                it was added. If the future has already completed or been
                cancelled then the callable will be called immediately. These
                callables are called in the order that they were added.
        """
        with self._condition:
            if self._state not in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]:
                self._done_callbacks.append(fn)
                return
        try:
            fn(self)
        except Exception:
            LOGGER.exception('exception calling callback for %r', self)

    def result(self, timeout=None):
        """Return the result of the call that the future represents.

        Args:
            timeout: The number of seconds to wait for the result if the future
                isn't done. If None, then there is no limit on the wait time.

        Returns:
            The result of the call that the future represents.

        Raises:
            CancelledError: If the future was cancelled.
            TimeoutError: If the future didn't finish executing before the given
                timeout.
            Exception: If the call raised then that exception will be raised.
        """
        try:
            with self._condition:
                if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
                    raise CancelledError()
                elif self._state == FINISHED:
                    return self.__get_result()

                self._condition.wait(timeout)

                if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
                    raise CancelledError()
                elif self._state == FINISHED:
                    return self.__get_result()
                else:
                    raise TimeoutError()
        finally:
            # Break a reference cycle with the exception in self._exception
            self = None

    def exception(self, timeout=None):
        """Return the exception raised by the call that the future represents.

        Args:
            timeout: The number of seconds to wait for the exception if the
                future isn't done. If None, then there is no limit on the wait
                time.

        Returns:
            The exception raised by the call that the future represents or None
            if the call completed without raising.

        Raises:
            CancelledError: If the future was cancelled.
            TimeoutError: If the future didn't finish executing before the given
                timeout.
        """

        with self._condition:
            if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
                raise CancelledError()
            elif self._state == FINISHED:
                return self._exception

            self._condition.wait(timeout)

            if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
                raise CancelledError()
            elif self._state == FINISHED:
                return self._exception
            else:
                raise TimeoutError()

    # The following methods should only be used by Executors and in tests.
    def set_running_or_notify_cancel(self):
        """Mark the future as running or process any cancel notifications.

        Should only be used by Executor implementations and unit tests.

        If the future has been cancelled (cancel() was called and returned
        True) then any threads waiting on the future completing (though calls
        to as_completed() or wait()) are notified and False is returned.

        If the future was not cancelled then it is put in the running state
        (future calls to running() will return True) and True is returned.

        This method should be called by Executor implementations before
        executing the work associated with this future. If this method returns
        False then the work should not be executed.

        Returns:
            False if the Future was cancelled, True otherwise.

        Raises:
            RuntimeError: if this method was already called or if set_result()
                or set_exception() was called.
        """
        with self._condition:
            if self._state == CANCELLED:
                self._state = CANCELLED_AND_NOTIFIED
                for waiter in self._waiters:
                    waiter.add_cancelled(self)
                # self._condition.notify_all() is not necessary because
                # self.cancel() triggers a notification.
                return False
            elif self._state == PENDING:
                self._state = RUNNING
                return True
            else:
                LOGGER.critical('Future %s in unexpected state: %s',
                                id(self),
                                self._state)
                raise RuntimeError('Future in unexpected state')

    def set_result(self, result):
        """Sets the return value of work associated with the future.

        Should only be used by Executor implementations and unit tests.
        """
        with self._condition:
            if self._state in {CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED}:
                raise InvalidStateError('{}: {!r}'.format(self._state, self))
            self._result = result
            self._state = FINISHED
            for waiter in self._waiters:
                waiter.add_result(self)
            self._condition.notify_all()
        self._invoke_callbacks()

    def set_exception(self, exception):
        """Sets the result of the future as being the given exception.

        Should only be used by Executor implementations and unit tests.
        """
        with self._condition:
            if self._state in {CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED}:
                raise InvalidStateError('{}: {!r}'.format(self._state, self))
            self._exception = exception
            self._state = FINISHED
            for waiter in self._waiters:
                waiter.add_exception(self)
            self._condition.notify_all()
        self._invoke_callbacks()

    __class_getitem__ = classmethod(types.GenericAlias)

class Executor(object):
    """This is an abstract base class for concrete asynchronous executors."""

    def submit(self, fn, /, *args, **kwargs):
        """Submits a callable to be executed with the given arguments.

        Schedules the callable to be executed as fn(*args, **kwargs) and returns
        a Future instance representing the execution of the callable.

        Returns:
            A Future representing the given call.
        """
        raise NotImplementedError()

    def map(self, fn, *iterables, timeout=None, chunksize=1):
        """Returns an iterator equivalent to map(fn, iter).

        Args:
            fn: A callable that will take as many arguments as there are
                passed iterables.
            timeout: The maximum number of seconds to wait. If None, then there
                is no limit on the wait time.
            chunksize: The size of the chunks the iterable will be broken into
                before being passed to a child process. This argument is only
                used by ProcessPoolExecutor; it is ignored by
                ThreadPoolExecutor.

        Returns:
            An iterator equivalent to: map(func, *iterables) but the calls may
            be evaluated out-of-order.

        Raises:
            TimeoutError: If the entire result iterator could not be generated
                before the given timeout.
            Exception: If fn(*args) raises for any values.
        """
        if timeout is not None:
            end_time = timeout + time.monotonic()

        fs = [self.submit(fn, *args) for args in zip(*iterables)]

        # Yield must be hidden in closure so that the futures are submitted
        # before the first iterator value is required.
        def result_iterator():
            try:
                # reverse to keep finishing order
                fs.reverse()
                while fs:
                    # Careful not to keep a reference to the popped future
                    if timeout is None:
                        yield _result_or_cancel(fs.pop())
                    else:
                        yield _result_or_cancel(fs.pop(), end_time - time.monotonic())
            finally:
                for future in fs:
                    future.cancel()
        return result_iterator()

    def shutdown(self, wait=True, *, cancel_futures=False):
        """Clean-up the resources associated with the Executor.

        It is safe to call this method several times. Otherwise, no other
        methods can be called after this one.

        Args:
            wait: If True then shutdown will not return until all running
                futures have finished executing and the resources used by the
                executor have been reclaimed.
            cancel_futures: If True then shutdown will cancel all pending
                futures. Futures that are completed or running will not be
                cancelled.
        """
        pass

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.shutdown(wait=True)
        return False


class BrokenExecutor(RuntimeError):
    """
    Raised when a executor has become non-functional after a severe failure.
    """
futures/process.py000064400000105227152402271140010276 0ustar00# Copyright 2009 Brian Quinlan. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Implements ProcessPoolExecutor.

The following diagram and text describe the data-flow through the system:

|======================= In-process =====================|== Out-of-process ==|

+----------+     +----------+       +--------+     +-----------+    +---------+
|          |  => | Work Ids |       |        |     | Call Q    |    | Process |
|          |     +----------+       |        |     +-----------+    |  Pool   |
|          |     | ...      |       |        |     | ...       |    +---------+
|          |     | 6        |    => |        |  => | 5, call() | => |         |
|          |     | 7        |       |        |     | ...       |    |         |
| Process  |     | ...      |       | Local  |     +-----------+    | Process |
|  Pool    |     +----------+       | Worker |                      |  #1..n  |
| Executor |                        | Thread |                      |         |
|          |     +----------- +     |        |     +-----------+    |         |
|          | <=> | Work Items | <=> |        | <=  | Result Q  | <= |         |
|          |     +------------+     |        |     +-----------+    |         |
|          |     | 6: call()  |     |        |     | ...       |    |         |
|          |     |    future  |     |        |     | 4, result |    |         |
|          |     | ...        |     |        |     | 3, except |    |         |
+----------+     +------------+     +--------+     +-----------+    +---------+

Executor.submit() called:
- creates a uniquely numbered _WorkItem and adds it to the "Work Items" dict
- adds the id of the _WorkItem to the "Work Ids" queue

Local worker thread:
- reads work ids from the "Work Ids" queue and looks up the corresponding
  WorkItem from the "Work Items" dict: if the work item has been cancelled then
  it is simply removed from the dict, otherwise it is repackaged as a
  _CallItem and put in the "Call Q". New _CallItems are put in the "Call Q"
  until "Call Q" is full. NOTE: the size of the "Call Q" is kept small because
  calls placed in the "Call Q" can no longer be cancelled with Future.cancel().
- reads _ResultItems from "Result Q", updates the future stored in the
  "Work Items" dict and deletes the dict entry

Process #1..n:
- reads _CallItems from "Call Q", executes the calls, and puts the resulting
  _ResultItems in "Result Q"
"""

__author__ = 'Brian Quinlan (brian@sweetapp.com)'

import os
from concurrent.futures import _base
import queue
import multiprocessing as mp
import multiprocessing.connection
from multiprocessing.queues import Queue
import threading
import weakref
from functools import partial
import itertools
import sys
from traceback import format_exception


_threads_wakeups = weakref.WeakKeyDictionary()
_global_shutdown = False


class _ThreadWakeup:
    def __init__(self):
        self._closed = False
        self._reader, self._writer = mp.Pipe(duplex=False)

    def close(self):
        # Please note that we do not take the shutdown lock when
        # calling clear() (to avoid deadlocking) so this method can
        # only be called safely from the same thread as all calls to
        # clear() even if you hold the shutdown lock. Otherwise we
        # might try to read from the closed pipe.
        if not self._closed:
            self._closed = True
            self._writer.close()
            self._reader.close()

    def wakeup(self):
        if not self._closed:
            self._writer.send_bytes(b"")

    def clear(self):
        if not self._closed:
            while self._reader.poll():
                self._reader.recv_bytes()


def _python_exit():
    global _global_shutdown
    _global_shutdown = True
    items = list(_threads_wakeups.items())
    for _, thread_wakeup in items:
        # call not protected by ProcessPoolExecutor._shutdown_lock
        thread_wakeup.wakeup()
    for t, _ in items:
        t.join()

# Register for `_python_exit()` to be called just before joining all
# non-daemon threads. This is used instead of `atexit.register()` for
# compatibility with subinterpreters, which no longer support daemon threads.
# See bpo-39812 for context.
threading._register_atexit(_python_exit)

# Controls how many more calls than processes will be queued in the call queue.
# A smaller number will mean that processes spend more time idle waiting for
# work while a larger number will make Future.cancel() succeed less frequently
# (Futures in the call queue cannot be cancelled).
EXTRA_QUEUED_CALLS = 1


# On Windows, WaitForMultipleObjects is used to wait for processes to finish.
# It can wait on, at most, 63 objects. There is an overhead of two objects:
# - the result queue reader
# - the thread wakeup reader
_MAX_WINDOWS_WORKERS = 63 - 2

# Hack to embed stringification of remote traceback in local traceback

class _RemoteTraceback(Exception):
    def __init__(self, tb):
        self.tb = tb
    def __str__(self):
        return self.tb

class _ExceptionWithTraceback:
    def __init__(self, exc, tb):
        tb = ''.join(format_exception(type(exc), exc, tb))
        self.exc = exc
        # Traceback object needs to be garbage-collected as its frames
        # contain references to all the objects in the exception scope
        self.exc.__traceback__ = None
        self.tb = '\n"""\n%s"""' % tb
    def __reduce__(self):
        return _rebuild_exc, (self.exc, self.tb)

def _rebuild_exc(exc, tb):
    exc.__cause__ = _RemoteTraceback(tb)
    return exc

class _WorkItem(object):
    def __init__(self, future, fn, args, kwargs):
        self.future = future
        self.fn = fn
        self.args = args
        self.kwargs = kwargs

class _ResultItem(object):
    def __init__(self, work_id, exception=None, result=None, exit_pid=None):
        self.work_id = work_id
        self.exception = exception
        self.result = result
        self.exit_pid = exit_pid

class _CallItem(object):
    def __init__(self, work_id, fn, args, kwargs):
        self.work_id = work_id
        self.fn = fn
        self.args = args
        self.kwargs = kwargs


class _SafeQueue(Queue):
    """Safe Queue set exception to the future object linked to a job"""
    def __init__(self, max_size=0, *, ctx, pending_work_items, shutdown_lock,
                 thread_wakeup):
        self.pending_work_items = pending_work_items
        self.shutdown_lock = shutdown_lock
        self.thread_wakeup = thread_wakeup
        super().__init__(max_size, ctx=ctx)

    def _on_queue_feeder_error(self, e, obj):
        if isinstance(obj, _CallItem):
            tb = format_exception(type(e), e, e.__traceback__)
            e.__cause__ = _RemoteTraceback('\n"""\n{}"""'.format(''.join(tb)))
            work_item = self.pending_work_items.pop(obj.work_id, None)
            with self.shutdown_lock:
                self.thread_wakeup.wakeup()
            # work_item can be None if another process terminated. In this
            # case, the executor_manager_thread fails all work_items
            # with BrokenProcessPool
            if work_item is not None:
                work_item.future.set_exception(e)
        else:
            super()._on_queue_feeder_error(e, obj)


def _get_chunks(*iterables, chunksize):
    """ Iterates over zip()ed iterables in chunks. """
    it = zip(*iterables)
    while True:
        chunk = tuple(itertools.islice(it, chunksize))
        if not chunk:
            return
        yield chunk


def _process_chunk(fn, chunk):
    """ Processes a chunk of an iterable passed to map.

    Runs the function passed to map() on a chunk of the
    iterable passed to map.

    This function is run in a separate process.

    """
    return [fn(*args) for args in chunk]


def _sendback_result(result_queue, work_id, result=None, exception=None,
                     exit_pid=None):
    """Safely send back the given result or exception"""
    try:
        result_queue.put(_ResultItem(work_id, result=result,
                                     exception=exception, exit_pid=exit_pid))
    except BaseException as e:
        exc = _ExceptionWithTraceback(e, e.__traceback__)
        result_queue.put(_ResultItem(work_id, exception=exc,
                                     exit_pid=exit_pid))


def _process_worker(call_queue, result_queue, initializer, initargs, max_tasks=None):
    """Evaluates calls from call_queue and places the results in result_queue.

    This worker is run in a separate process.

    Args:
        call_queue: A ctx.Queue of _CallItems that will be read and
            evaluated by the worker.
        result_queue: A ctx.Queue of _ResultItems that will written
            to by the worker.
        initializer: A callable initializer, or None
        initargs: A tuple of args for the initializer
    """
    if initializer is not None:
        try:
            initializer(*initargs)
        except BaseException:
            _base.LOGGER.critical('Exception in initializer:', exc_info=True)
            # The parent will notice that the process stopped and
            # mark the pool broken
            return
    num_tasks = 0
    exit_pid = None
    while True:
        call_item = call_queue.get(block=True)
        if call_item is None:
            # Wake up queue management thread
            result_queue.put(os.getpid())
            return

        if max_tasks is not None:
            num_tasks += 1
            if num_tasks >= max_tasks:
                exit_pid = os.getpid()

        try:
            r = call_item.fn(*call_item.args, **call_item.kwargs)
        except BaseException as e:
            exc = _ExceptionWithTraceback(e, e.__traceback__)
            _sendback_result(result_queue, call_item.work_id, exception=exc,
                             exit_pid=exit_pid)
        else:
            _sendback_result(result_queue, call_item.work_id, result=r,
                             exit_pid=exit_pid)
            del r

        # Liberate the resource as soon as possible, to avoid holding onto
        # open files or shared memory that is not needed anymore
        del call_item

        if exit_pid is not None:
            return


class _ExecutorManagerThread(threading.Thread):
    """Manages the communication between this process and the worker processes.

    The manager is run in a local thread.

    Args:
        executor: A reference to the ProcessPoolExecutor that owns
            this thread. A weakref will be own by the manager as well as
            references to internal objects used to introspect the state of
            the executor.
    """

    def __init__(self, executor):
        # Store references to necessary internals of the executor.

        # A _ThreadWakeup to allow waking up the queue_manager_thread from the
        # main Thread and avoid deadlocks caused by permanently locked queues.
        self.thread_wakeup = executor._executor_manager_thread_wakeup
        self.shutdown_lock = executor._shutdown_lock

        # A weakref.ref to the ProcessPoolExecutor that owns this thread. Used
        # to determine if the ProcessPoolExecutor has been garbage collected
        # and that the manager can exit.
        # When the executor gets garbage collected, the weakref callback
        # will wake up the queue management thread so that it can terminate
        # if there is no pending work item.
        def weakref_cb(_,
                       thread_wakeup=self.thread_wakeup,
                       shutdown_lock=self.shutdown_lock):
            mp.util.debug('Executor collected: triggering callback for'
                          ' QueueManager wakeup')
            with shutdown_lock:
                thread_wakeup.wakeup()

        self.executor_reference = weakref.ref(executor, weakref_cb)

        # A list of the ctx.Process instances used as workers.
        self.processes = executor._processes

        # A ctx.Queue that will be filled with _CallItems derived from
        # _WorkItems for processing by the process workers.
        self.call_queue = executor._call_queue

        # A ctx.SimpleQueue of _ResultItems generated by the process workers.
        self.result_queue = executor._result_queue

        # A queue.Queue of work ids e.g. Queue([5, 6, ...]).
        self.work_ids_queue = executor._work_ids

        # Maximum number of tasks a worker process can execute before
        # exiting safely
        self.max_tasks_per_child = executor._max_tasks_per_child

        # A dict mapping work ids to _WorkItems e.g.
        #     {5: <_WorkItem...>, 6: <_WorkItem...>, ...}
        self.pending_work_items = executor._pending_work_items

        super().__init__()

    def run(self):
        # Main loop for the executor manager thread.

        while True:
            self.add_call_item_to_queue()

            result_item, is_broken, cause = self.wait_result_broken_or_wakeup()

            if is_broken:
                self.terminate_broken(cause)
                return
            if result_item is not None:
                self.process_result_item(result_item)

                process_exited = result_item.exit_pid is not None
                if process_exited:
                    p = self.processes.pop(result_item.exit_pid)
                    p.join()

                # Delete reference to result_item to avoid keeping references
                # while waiting on new results.
                del result_item

                if executor := self.executor_reference():
                    if process_exited:
                        with self.shutdown_lock:
                            executor._adjust_process_count()
                    else:
                        executor._idle_worker_semaphore.release()
                    del executor

            if self.is_shutting_down():
                self.flag_executor_shutting_down()

                # When only canceled futures remain in pending_work_items, our
                # next call to wait_result_broken_or_wakeup would hang forever.
                # This makes sure we have some running futures or none at all.
                self.add_call_item_to_queue()

                # Since no new work items can be added, it is safe to shutdown
                # this thread if there are no pending work items.
                if not self.pending_work_items:
                    self.join_executor_internals()
                    return

    def add_call_item_to_queue(self):
        # Fills call_queue with _WorkItems from pending_work_items.
        # This function never blocks.
        while True:
            if self.call_queue.full():
                return
            try:
                work_id = self.work_ids_queue.get(block=False)
            except queue.Empty:
                return
            else:
                work_item = self.pending_work_items[work_id]

                if work_item.future.set_running_or_notify_cancel():
                    self.call_queue.put(_CallItem(work_id,
                                                  work_item.fn,
                                                  work_item.args,
                                                  work_item.kwargs),
                                        block=True)
                else:
                    del self.pending_work_items[work_id]
                    continue

    def wait_result_broken_or_wakeup(self):
        # Wait for a result to be ready in the result_queue while checking
        # that all worker processes are still running, or for a wake up
        # signal send. The wake up signals come either from new tasks being
        # submitted, from the executor being shutdown/gc-ed, or from the
        # shutdown of the python interpreter.
        result_reader = self.result_queue._reader
        assert not self.thread_wakeup._closed
        wakeup_reader = self.thread_wakeup._reader
        readers = [result_reader, wakeup_reader]
        worker_sentinels = [p.sentinel for p in list(self.processes.values())]
        ready = mp.connection.wait(readers + worker_sentinels)

        cause = None
        is_broken = True
        result_item = None
        if result_reader in ready:
            try:
                result_item = result_reader.recv()
                is_broken = False
            except BaseException as e:
                cause = format_exception(type(e), e, e.__traceback__)

        elif wakeup_reader in ready:
            is_broken = False

        # No need to hold the _shutdown_lock here because:
        # 1. we're the only thread to use the wakeup reader
        # 2. we're also the only thread to call thread_wakeup.close()
        # 3. we want to avoid a possible deadlock when both reader and writer
        #    would block (gh-105829)
        self.thread_wakeup.clear()

        return result_item, is_broken, cause

    def process_result_item(self, result_item):
        # Process the received a result_item. This can be either the PID of a
        # worker that exited gracefully or a _ResultItem

        if isinstance(result_item, int):
            # Clean shutdown of a worker using its PID
            # (avoids marking the executor broken)
            assert self.is_shutting_down()
            p = self.processes.pop(result_item)
            p.join()
            if not self.processes:
                self.join_executor_internals()
                return
        else:
            # Received a _ResultItem so mark the future as completed.
            work_item = self.pending_work_items.pop(result_item.work_id, None)
            # work_item can be None if another process terminated (see above)
            if work_item is not None:
                if result_item.exception:
                    work_item.future.set_exception(result_item.exception)
                else:
                    work_item.future.set_result(result_item.result)

    def is_shutting_down(self):
        # Check whether we should start shutting down the executor.
        executor = self.executor_reference()
        # No more work items can be added if:
        #   - The interpreter is shutting down OR
        #   - The executor that owns this worker has been collected OR
        #   - The executor that owns this worker has been shutdown.
        return (_global_shutdown or executor is None
                or executor._shutdown_thread)

    def terminate_broken(self, cause):
        # Terminate the executor because it is in a broken state. The cause
        # argument can be used to display more information on the error that
        # lead the executor into becoming broken.

        # Mark the process pool broken so that submits fail right now.
        executor = self.executor_reference()
        if executor is not None:
            executor._broken = ('A child process terminated '
                                'abruptly, the process pool is not '
                                'usable anymore')
            executor._shutdown_thread = True
            executor = None

        # All pending tasks are to be marked failed with the following
        # BrokenProcessPool error
        bpe = BrokenProcessPool("A process in the process pool was "
                                "terminated abruptly while the future was "
                                "running or pending.")
        if cause is not None:
            bpe.__cause__ = _RemoteTraceback(
                f"\n'''\n{''.join(cause)}'''")

        # Mark pending tasks as failed.
        for work_id, work_item in self.pending_work_items.items():
            work_item.future.set_exception(bpe)
            # Delete references to object. See issue16284
            del work_item
        self.pending_work_items.clear()

        # Terminate remaining workers forcibly: the queues or their
        # locks may be in a dirty state and block forever.
        for p in self.processes.values():
            p.terminate()

        # Prevent queue writing to a pipe which is no longer read.
        # https://github.com/python/cpython/issues/94777
        self.call_queue._reader.close()

        # gh-107219: Close the connection writer which can unblock
        # Queue._feed() if it was stuck in send_bytes().
        if sys.platform == 'win32':
            self.call_queue._writer.close()

        # clean up resources
        self.join_executor_internals()

    def flag_executor_shutting_down(self):
        # Flag the executor as shutting down and cancel remaining tasks if
        # requested as early as possible if it is not gc-ed yet.
        executor = self.executor_reference()
        if executor is not None:
            executor._shutdown_thread = True
            # Cancel pending work items if requested.
            if executor._cancel_pending_futures:
                # Cancel all pending futures and update pending_work_items
                # to only have futures that are currently running.
                new_pending_work_items = {}
                for work_id, work_item in self.pending_work_items.items():
                    if not work_item.future.cancel():
                        new_pending_work_items[work_id] = work_item
                self.pending_work_items = new_pending_work_items
                # Drain work_ids_queue since we no longer need to
                # add items to the call queue.
                while True:
                    try:
                        self.work_ids_queue.get_nowait()
                    except queue.Empty:
                        break
                # Make sure we do this only once to not waste time looping
                # on running processes over and over.
                executor._cancel_pending_futures = False

    def shutdown_workers(self):
        n_children_to_stop = self.get_n_children_alive()
        n_sentinels_sent = 0
        # Send the right number of sentinels, to make sure all children are
        # properly terminated.
        while (n_sentinels_sent < n_children_to_stop
                and self.get_n_children_alive() > 0):
            for i in range(n_children_to_stop - n_sentinels_sent):
                try:
                    self.call_queue.put_nowait(None)
                    n_sentinels_sent += 1
                except queue.Full:
                    break

    def join_executor_internals(self):
        self.shutdown_workers()
        # Release the queue's resources as soon as possible.
        self.call_queue.close()
        self.call_queue.join_thread()
        with self.shutdown_lock:
            self.thread_wakeup.close()
        # If .join() is not called on the created processes then
        # some ctx.Queue methods may deadlock on Mac OS X.
        for p in self.processes.values():
            p.join()

    def get_n_children_alive(self):
        # This is an upper bound on the number of children alive.
        return sum(p.is_alive() for p in self.processes.values())


_system_limits_checked = False
_system_limited = None


def _check_system_limits():
    global _system_limits_checked, _system_limited
    if _system_limits_checked:
        if _system_limited:
            raise NotImplementedError(_system_limited)
    _system_limits_checked = True
    try:
        import multiprocessing.synchronize
    except ImportError:
        _system_limited = (
            "This Python build lacks multiprocessing.synchronize, usually due "
            "to named semaphores being unavailable on this platform."
        )
        raise NotImplementedError(_system_limited)
    try:
        nsems_max = os.sysconf("SC_SEM_NSEMS_MAX")
    except (AttributeError, ValueError):
        # sysconf not available or setting not available
        return
    if nsems_max == -1:
        # indetermined limit, assume that limit is determined
        # by available memory only
        return
    if nsems_max >= 256:
        # minimum number of semaphores available
        # according to POSIX
        return
    _system_limited = ("system provides too few semaphores (%d"
                       " available, 256 necessary)" % nsems_max)
    raise NotImplementedError(_system_limited)


def _chain_from_iterable_of_lists(iterable):
    """
    Specialized implementation of itertools.chain.from_iterable.
    Each item in *iterable* should be a list.  This function is
    careful not to keep references to yielded objects.
    """
    for element in iterable:
        element.reverse()
        while element:
            yield element.pop()


class BrokenProcessPool(_base.BrokenExecutor):
    """
    Raised when a process in a ProcessPoolExecutor terminated abruptly
    while a future was in the running state.
    """


class ProcessPoolExecutor(_base.Executor):
    def __init__(self, max_workers=None, mp_context=None,
                 initializer=None, initargs=(), *, max_tasks_per_child=None):
        """Initializes a new ProcessPoolExecutor instance.

        Args:
            max_workers: The maximum number of processes that can be used to
                execute the given calls. If None or not given then as many
                worker processes will be created as the machine has processors.
            mp_context: A multiprocessing context to launch the workers. This
                object should provide SimpleQueue, Queue and Process. Useful
                to allow specific multiprocessing start methods.
            initializer: A callable used to initialize worker processes.
            initargs: A tuple of arguments to pass to the initializer.
            max_tasks_per_child: The maximum number of tasks a worker process
                can complete before it will exit and be replaced with a fresh
                worker process. The default of None means worker process will
                live as long as the executor. Requires a non-'fork' mp_context
                start method. When given, we default to using 'spawn' if no
                mp_context is supplied.
        """
        _check_system_limits()

        if max_workers is None:
            self._max_workers = os.cpu_count() or 1
            if sys.platform == 'win32':
                self._max_workers = min(_MAX_WINDOWS_WORKERS,
                                        self._max_workers)
        else:
            if max_workers <= 0:
                raise ValueError("max_workers must be greater than 0")
            elif (sys.platform == 'win32' and
                max_workers > _MAX_WINDOWS_WORKERS):
                raise ValueError(
                    f"max_workers must be <= {_MAX_WINDOWS_WORKERS}")

            self._max_workers = max_workers

        if mp_context is None:
            if max_tasks_per_child is not None:
                mp_context = mp.get_context("spawn")
            else:
                mp_context = mp.get_context()
        self._mp_context = mp_context

        # https://github.com/python/cpython/issues/90622
        self._safe_to_dynamically_spawn_children = (
                self._mp_context.get_start_method(allow_none=False) != "fork")

        if initializer is not None and not callable(initializer):
            raise TypeError("initializer must be a callable")
        self._initializer = initializer
        self._initargs = initargs

        if max_tasks_per_child is not None:
            if not isinstance(max_tasks_per_child, int):
                raise TypeError("max_tasks_per_child must be an integer")
            elif max_tasks_per_child <= 0:
                raise ValueError("max_tasks_per_child must be >= 1")
            if self._mp_context.get_start_method(allow_none=False) == "fork":
                # https://github.com/python/cpython/issues/90622
                raise ValueError("max_tasks_per_child is incompatible with"
                                 " the 'fork' multiprocessing start method;"
                                 " supply a different mp_context.")
        self._max_tasks_per_child = max_tasks_per_child

        # Management thread
        self._executor_manager_thread = None

        # Map of pids to processes
        self._processes = {}

        # Shutdown is a two-step process.
        self._shutdown_thread = False
        self._shutdown_lock = threading.Lock()
        self._idle_worker_semaphore = threading.Semaphore(0)
        self._broken = False
        self._queue_count = 0
        self._pending_work_items = {}
        self._cancel_pending_futures = False

        # _ThreadWakeup is a communication channel used to interrupt the wait
        # of the main loop of executor_manager_thread from another thread (e.g.
        # when calling executor.submit or executor.shutdown). We do not use the
        # _result_queue to send wakeup signals to the executor_manager_thread
        # as it could result in a deadlock if a worker process dies with the
        # _result_queue write lock still acquired.
        #
        # _shutdown_lock must be locked to access _ThreadWakeup.close() and
        # .wakeup(). Care must also be taken to not call clear or close from
        # more than one thread since _ThreadWakeup.clear() is not protected by
        # the _shutdown_lock
        self._executor_manager_thread_wakeup = _ThreadWakeup()

        # Create communication channels for the executor
        # Make the call queue slightly larger than the number of processes to
        # prevent the worker processes from idling. But don't make it too big
        # because futures in the call queue cannot be cancelled.
        queue_size = self._max_workers + EXTRA_QUEUED_CALLS
        self._call_queue = _SafeQueue(
            max_size=queue_size, ctx=self._mp_context,
            pending_work_items=self._pending_work_items,
            shutdown_lock=self._shutdown_lock,
            thread_wakeup=self._executor_manager_thread_wakeup)
        # Killed worker processes can produce spurious "broken pipe"
        # tracebacks in the queue's own worker thread. But we detect killed
        # processes anyway, so silence the tracebacks.
        self._call_queue._ignore_epipe = True
        self._result_queue = mp_context.SimpleQueue()
        self._work_ids = queue.Queue()

    def _start_executor_manager_thread(self):
        if self._executor_manager_thread is None:
            # Start the processes so that their sentinels are known.
            if not self._safe_to_dynamically_spawn_children:  # ie, using fork.
                self._launch_processes()
            self._executor_manager_thread = _ExecutorManagerThread(self)
            self._executor_manager_thread.start()
            _threads_wakeups[self._executor_manager_thread] = \
                self._executor_manager_thread_wakeup

    def _adjust_process_count(self):
        # if there's an idle process, we don't need to spawn a new one.
        if self._idle_worker_semaphore.acquire(blocking=False):
            return

        process_count = len(self._processes)
        if process_count < self._max_workers:
            # Assertion disabled as this codepath is also used to replace a
            # worker that unexpectedly dies, even when using the 'fork' start
            # method. That means there is still a potential deadlock bug. If a
            # 'fork' mp_context worker dies, we'll be forking a new one when
            # we know a thread is running (self._executor_manager_thread).
            #assert self._safe_to_dynamically_spawn_children or not self._executor_manager_thread, 'https://github.com/python/cpython/issues/90622'
            self._spawn_process()

    def _launch_processes(self):
        # https://github.com/python/cpython/issues/90622
        assert not self._executor_manager_thread, (
                'Processes cannot be fork()ed after the thread has started, '
                'deadlock in the child processes could result.')
        for _ in range(len(self._processes), self._max_workers):
            self._spawn_process()

    def _spawn_process(self):
        p = self._mp_context.Process(
            target=_process_worker,
            args=(self._call_queue,
                  self._result_queue,
                  self._initializer,
                  self._initargs,
                  self._max_tasks_per_child))
        p.start()
        self._processes[p.pid] = p

    def submit(self, fn, /, *args, **kwargs):
        with self._shutdown_lock:
            if self._broken:
                raise BrokenProcessPool(self._broken)
            if self._shutdown_thread:
                raise RuntimeError('cannot schedule new futures after shutdown')
            if _global_shutdown:
                raise RuntimeError('cannot schedule new futures after '
                                   'interpreter shutdown')

            f = _base.Future()
            w = _WorkItem(f, fn, args, kwargs)

            self._pending_work_items[self._queue_count] = w
            self._work_ids.put(self._queue_count)
            self._queue_count += 1
            # Wake up queue management thread
            self._executor_manager_thread_wakeup.wakeup()

            if self._safe_to_dynamically_spawn_children:
                self._adjust_process_count()
            self._start_executor_manager_thread()
            return f
    submit.__doc__ = _base.Executor.submit.__doc__

    def map(self, fn, *iterables, timeout=None, chunksize=1):
        """Returns an iterator equivalent to map(fn, iter).

        Args:
            fn: A callable that will take as many arguments as there are
                passed iterables.
            timeout: The maximum number of seconds to wait. If None, then there
                is no limit on the wait time.
            chunksize: If greater than one, the iterables will be chopped into
                chunks of size chunksize and submitted to the process pool.
                If set to one, the items in the list will be sent one at a time.

        Returns:
            An iterator equivalent to: map(func, *iterables) but the calls may
            be evaluated out-of-order.

        Raises:
            TimeoutError: If the entire result iterator could not be generated
                before the given timeout.
            Exception: If fn(*args) raises for any values.
        """
        if chunksize < 1:
            raise ValueError("chunksize must be >= 1.")

        results = super().map(partial(_process_chunk, fn),
                              _get_chunks(*iterables, chunksize=chunksize),
                              timeout=timeout)
        return _chain_from_iterable_of_lists(results)

    def shutdown(self, wait=True, *, cancel_futures=False):
        with self._shutdown_lock:
            self._cancel_pending_futures = cancel_futures
            self._shutdown_thread = True
            if self._executor_manager_thread_wakeup is not None:
                # Wake up queue management thread
                self._executor_manager_thread_wakeup.wakeup()

        if self._executor_manager_thread is not None and wait:
            self._executor_manager_thread.join()
        # To reduce the risk of opening too many files, remove references to
        # objects that use file descriptors.
        self._executor_manager_thread = None
        self._call_queue = None
        if self._result_queue is not None and wait:
            self._result_queue.close()
        self._result_queue = None
        self._processes = None
        self._executor_manager_thread_wakeup = None

    shutdown.__doc__ = _base.Executor.shutdown.__doc__
futures/thread.py000064400000021103152402271140010055 0ustar00# Copyright 2009 Brian Quinlan. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Implements ThreadPoolExecutor."""

__author__ = 'Brian Quinlan (brian@sweetapp.com)'

from concurrent.futures import _base
import itertools
import queue
import threading
import types
import weakref
import os


_threads_queues = weakref.WeakKeyDictionary()
_shutdown = False
# Lock that ensures that new workers are not created while the interpreter is
# shutting down. Must be held while mutating _threads_queues and _shutdown.
_global_shutdown_lock = threading.Lock()

def _python_exit():
    global _shutdown
    with _global_shutdown_lock:
        _shutdown = True
    items = list(_threads_queues.items())
    for t, q in items:
        q.put(None)
    for t, q in items:
        t.join()

# Register for `_python_exit()` to be called just before joining all
# non-daemon threads. This is used instead of `atexit.register()` for
# compatibility with subinterpreters, which no longer support daemon threads.
# See bpo-39812 for context.
threading._register_atexit(_python_exit)

# At fork, reinitialize the `_global_shutdown_lock` lock in the child process
if hasattr(os, 'register_at_fork'):
    os.register_at_fork(before=_global_shutdown_lock.acquire,
                        after_in_child=_global_shutdown_lock._at_fork_reinit,
                        after_in_parent=_global_shutdown_lock.release)


class _WorkItem(object):
    def __init__(self, future, fn, args, kwargs):
        self.future = future
        self.fn = fn
        self.args = args
        self.kwargs = kwargs

    def run(self):
        if not self.future.set_running_or_notify_cancel():
            return

        try:
            result = self.fn(*self.args, **self.kwargs)
        except BaseException as exc:
            self.future.set_exception(exc)
            # Break a reference cycle with the exception 'exc'
            self = None
        else:
            self.future.set_result(result)

    __class_getitem__ = classmethod(types.GenericAlias)


def _worker(executor_reference, work_queue, initializer, initargs):
    if initializer is not None:
        try:
            initializer(*initargs)
        except BaseException:
            _base.LOGGER.critical('Exception in initializer:', exc_info=True)
            executor = executor_reference()
            if executor is not None:
                executor._initializer_failed()
            return
    try:
        while True:
            work_item = work_queue.get(block=True)
            if work_item is not None:
                work_item.run()
                # Delete references to object. See issue16284
                del work_item

                # attempt to increment idle count
                executor = executor_reference()
                if executor is not None:
                    executor._idle_semaphore.release()
                del executor
                continue

            executor = executor_reference()
            # Exit if:
            #   - The interpreter is shutting down OR
            #   - The executor that owns the worker has been collected OR
            #   - The executor that owns the worker has been shutdown.
            if _shutdown or executor is None or executor._shutdown:
                # Flag the executor as shutting down as early as possible if it
                # is not gc-ed yet.
                if executor is not None:
                    executor._shutdown = True
                # Notice other workers
                work_queue.put(None)
                return
            del executor
    except BaseException:
        _base.LOGGER.critical('Exception in worker', exc_info=True)


class BrokenThreadPool(_base.BrokenExecutor):
    """
    Raised when a worker thread in a ThreadPoolExecutor failed initializing.
    """


class ThreadPoolExecutor(_base.Executor):

    # Used to assign unique thread names when thread_name_prefix is not supplied.
    _counter = itertools.count().__next__

    def __init__(self, max_workers=None, thread_name_prefix='',
                 initializer=None, initargs=()):
        """Initializes a new ThreadPoolExecutor instance.

        Args:
            max_workers: The maximum number of threads that can be used to
                execute the given calls.
            thread_name_prefix: An optional name prefix to give our threads.
            initializer: A callable used to initialize worker threads.
            initargs: A tuple of arguments to pass to the initializer.
        """
        if max_workers is None:
            # ThreadPoolExecutor is often used to:
            # * CPU bound task which releases GIL
            # * I/O bound task (which releases GIL, of course)
            #
            # We use cpu_count + 4 for both types of tasks.
            # But we limit it to 32 to avoid consuming surprisingly large resource
            # on many core machine.
            max_workers = min(32, (os.cpu_count() or 1) + 4)
        if max_workers <= 0:
            raise ValueError("max_workers must be greater than 0")

        if initializer is not None and not callable(initializer):
            raise TypeError("initializer must be a callable")

        self._max_workers = max_workers
        self._work_queue = queue.SimpleQueue()
        self._idle_semaphore = threading.Semaphore(0)
        self._threads = set()
        self._broken = False
        self._shutdown = False
        self._shutdown_lock = threading.Lock()
        self._thread_name_prefix = (thread_name_prefix or
                                    ("ThreadPoolExecutor-%d" % self._counter()))
        self._initializer = initializer
        self._initargs = initargs

    def submit(self, fn, /, *args, **kwargs):
        with self._shutdown_lock, _global_shutdown_lock:
            if self._broken:
                raise BrokenThreadPool(self._broken)

            if self._shutdown:
                raise RuntimeError('cannot schedule new futures after shutdown')
            if _shutdown:
                raise RuntimeError('cannot schedule new futures after '
                                   'interpreter shutdown')

            f = _base.Future()
            w = _WorkItem(f, fn, args, kwargs)

            self._work_queue.put(w)
            self._adjust_thread_count()
            return f
    submit.__doc__ = _base.Executor.submit.__doc__

    def _adjust_thread_count(self):
        # if idle threads are available, don't spin new threads
        if self._idle_semaphore.acquire(timeout=0):
            return

        # When the executor gets lost, the weakref callback will wake up
        # the worker threads.
        def weakref_cb(_, q=self._work_queue):
            q.put(None)

        num_threads = len(self._threads)
        if num_threads < self._max_workers:
            thread_name = '%s_%d' % (self._thread_name_prefix or self,
                                     num_threads)
            t = threading.Thread(name=thread_name, target=_worker,
                                 args=(weakref.ref(self, weakref_cb),
                                       self._work_queue,
                                       self._initializer,
                                       self._initargs))
            t.start()
            self._threads.add(t)
            _threads_queues[t] = self._work_queue

    def _initializer_failed(self):
        with self._shutdown_lock:
            self._broken = ('A thread initializer failed, the thread pool '
                            'is not usable anymore')
            # Drain work queue and mark pending futures failed
            while True:
                try:
                    work_item = self._work_queue.get_nowait()
                except queue.Empty:
                    break
                if work_item is not None:
                    work_item.future.set_exception(BrokenThreadPool(self._broken))

    def shutdown(self, wait=True, *, cancel_futures=False):
        with self._shutdown_lock:
            self._shutdown = True
            if cancel_futures:
                # Drain all work items from the queue, and then cancel their
                # associated futures.
                while True:
                    try:
                        work_item = self._work_queue.get_nowait()
                    except queue.Empty:
                        break
                    if work_item is not None:
                        work_item.future.cancel()

            # Send a wake-up to prevent threads calling
            # _work_queue.get(block=True) from permanently blocking.
            self._work_queue.put(None)
        if wait:
            for t in self._threads:
                t.join()
    shutdown.__doc__ = _base.Executor.shutdown.__doc__
futures/__init__.py000064400000003026152402271140010351 0ustar00# Copyright 2009 Brian Quinlan. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Execute computations asynchronously using threads or processes."""

__author__ = 'Brian Quinlan (brian@sweetapp.com)'

from concurrent.futures._base import (FIRST_COMPLETED,
                                      FIRST_EXCEPTION,
                                      ALL_COMPLETED,
                                      CancelledError,
                                      TimeoutError,
                                      InvalidStateError,
                                      BrokenExecutor,
                                      Future,
                                      Executor,
                                      wait,
                                      as_completed)

__all__ = (
    'FIRST_COMPLETED',
    'FIRST_EXCEPTION',
    'ALL_COMPLETED',
    'CancelledError',
    'TimeoutError',
    'BrokenExecutor',
    'Future',
    'Executor',
    'wait',
    'as_completed',
    'ProcessPoolExecutor',
    'ThreadPoolExecutor',
)


def __dir__():
    return __all__ + ('__author__', '__doc__')


def __getattr__(name):
    global ProcessPoolExecutor, ThreadPoolExecutor

    if name == 'ProcessPoolExecutor':
        from .process import ProcessPoolExecutor as pe
        ProcessPoolExecutor = pe
        return pe

    if name == 'ThreadPoolExecutor':
        from .thread import ThreadPoolExecutor as te
        ThreadPoolExecutor = te
        return te

    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
futures/__pycache__/_base.cpython-311.pyc000064400000110626152402271140014230 0ustar00�

��-8q'��
��dZddlZddlZddlZddlZddlZdZdZdZdZ	dZ
dZd	Zd
Z
dZe
eee
egZe
ded
ede
dediZejd��ZGd�de��ZGd�de��ZeZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�d e��Zd!�Zd"�Zd.d#�Z ej!d$d%��Z"defd&�Z#d.d'�Z$Gd(�d)e��Z%Gd*�d+e��Z&Gd,�d-e'��Z(dS)/z"Brian Quinlan (brian@sweetapp.com)�N�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�
_AS_COMPLETED�PENDING�RUNNING�	CANCELLED�CANCELLED_AND_NOTIFIED�FINISHED�pending�running�	cancelled�finishedzconcurrent.futuresc��eZdZdZdS)�Errorz-Base class for all future-related exceptions.N��__name__�
__module__�__qualname__�__doc__���C/opt/alt/python-internal/lib/python3.11/concurrent/futures/_base.pyrr-s������7�7��Drrc��eZdZdZdS)�CancelledErrorzThe Future was cancelled.Nrrrrrr1s������#�#��Drrc��eZdZdZdS)�InvalidStateErrorz+The operation is not allowed in this state.Nrrrrrr7s������5�5��Drrc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�_Waiterz;Provides the event that wait() and as_completed() block on.c�D�tj��|_g|_dS�N)�	threading�Event�event�finished_futures��selfs r�__init__z_Waiter.__init__=s���_�&�&��
� "����rc�:�|j�|��dSr!�r%�append�r'�futures  r�
add_resultz_Waiter.add_resultA�����$�$�V�,�,�,�,�,rc�:�|j�|��dSr!r*r,s  r�
add_exceptionz_Waiter.add_exceptionDr/rc�:�|j�|��dSr!r*r,s  r�
add_cancelledz_Waiter.add_cancelledGr/rN)rrrrr(r.r1r3rrrrr;sV������E�E�#�#�#�-�-�-�-�-�-�-�-�-�-�-rrc�@��eZdZdZ�fd�Z�fd�Z�fd�Z�fd�Z�xZS)�_AsCompletedWaiterzUsed by as_completed().c���tt|�����tj��|_dSr!)�superr5r(r"�Lock�lock)r'�	__class__s �rr(z_AsCompletedWaiter.__init__Ms3���
� �$�'�'�0�0�2�2�2��N�$�$��	�	�	rc����|j5tt|���|��|j���ddd��dS#1swxYwYdSr!)r9r7r5r.r$�set�r'r-r:s  �rr.z_AsCompletedWaiter.add_resultQs����
�Y�	�	��$�d�+�+�6�6�v�>�>�>��J�N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��AA�A�Ac����|j5tt|���|��|j���ddd��dS#1swxYwYdSr!)r9r7r5r1r$r<r=s  �rr1z _AsCompletedWaiter.add_exceptionV����
�Y�	�	��$�d�+�+�9�9�&�A�A�A��J�N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r>c����|j5tt|���|��|j���ddd��dS#1swxYwYdSr!)r9r7r5r3r$r<r=s  �rr3z _AsCompletedWaiter.add_cancelled[r@r>)	rrrrr(r.r1r3�
__classcell__�r:s@rr5r5Js��������!�!�%�%�%�%�%������
�����
��������rr5c�6��eZdZdZ�fd�Z�fd�Z�fd�Z�xZS)�_FirstCompletedWaiterz*Used by wait(return_when=FIRST_COMPLETED).c�|��t���|��|j���dSr!)r7r.r$r<r=s  �rr.z _FirstCompletedWaiter.add_resultcs3���
�����6�"�"�"��
�������rc�|��t���|��|j���dSr!)r7r1r$r<r=s  �rr1z#_FirstCompletedWaiter.add_exceptiong�3���
�����f�%�%�%��
�������rc�|��t���|��|j���dSr!)r7r3r$r<r=s  �rr3z#_FirstCompletedWaiter.add_cancelledkrHr)rrrrr.r1r3rBrCs@rrErE`sp�������4�4�������������������rrEc�F��eZdZdZ�fd�Zd�Z�fd�Z�fd�Z�fd�Z�xZ	S)�_AllCompletedWaiterz<Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED).c���||_||_tj��|_t�����dSr!)�num_pending_calls�stop_on_exceptionr"r8r9r7r()r'rMrNr:s   �rr(z_AllCompletedWaiter.__init__rs>���!2���!2����N�$�$��	�
���������rc��|j5|xjdzc_|js|j���ddd��dS#1swxYwYdS)N�)r9rMr$r<r&s r�_decrement_pending_callsz,_AllCompletedWaiter._decrement_pending_callsxs���
�Y�	!�	!��"�"�a�'�"�"��)�
!��
��� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�	!�	!s�1A�A
�
A
c�r��t���|��|���dSr!)r7r.rQr=s  �rr.z_AllCompletedWaiter.add_result~s3���
�����6�"�"�"��%�%�'�'�'�'�'rc���t���|��|jr|j���dS|���dSr!)r7r1rNr$r<rQr=s  �rr1z!_AllCompletedWaiter.add_exception�sV���
�����f�%�%�%��!�	,��J�N�N�������)�)�+�+�+�+�+rc�r��t���|��|���dSr!)r7r3rQr=s  �rr3z!_AllCompletedWaiter.add_cancelled�s3���
�����f�%�%�%��%�%�'�'�'�'�'r)
rrrrr(rQr.r1r3rBrCs@rrKrKos��������F�F������!�!�!�(�(�(�(�(�,�,�,�,�,�(�(�(�(�(�(�(�(�(rrKc�$�eZdZdZd�Zd�Zd�ZdS)�_AcquireFutureszDA context manager that does an ordered acquire of Future conditions.c�<�t|t���|_dS)N)�key)�sorted�id�futures)r'r[s  rr(z_AcquireFutures.__init__�s���g�2�.�.�.����rc�L�|jD]}|j����dSr!)r[�
_condition�acquirer,s  r�	__enter__z_AcquireFutures.__enter__��5���l�	(�	(�F���%�%�'�'�'�'�	(�	(rc�L�|jD]}|j����dSr!)r[r]�release)r'�argsr-s   r�__exit__z_AcquireFutures.__exit__�r`rN)rrrrr(r_rdrrrrVrV�sG������N�N�/�/�/�(�(�(�(�(�(�(�(rrVc�v�|tkrt��}n|tkrt��}net	d�|D����}|t
krt
|d���}n/|tkrt
|d���}ntd|z���|D]}|j	�
|���|S)Nc3�@K�|]}|jttfvV��dSr!��_stater
r��.0�fs  r�	<genexpr>z._create_and_install_waiters.<locals>.<genexpr>�sH����P�P�GH���!7�� B�B�P�P�P�P�P�PrT)rNFzInvalid return condition: %r)rr5rrE�sumrrKr�
ValueError�_waitersr+)�fs�return_when�waiter�
pending_countrks     r�_create_and_install_waitersrt�s����m�#�#�#�%�%���	��	'�	'�&�(�(����P�P�LN�P�P�P�P�P�
��/�)�)�(��$�O�O�O�F�F�
�M�
)�
)�(��%�P�P�P�F�F��;�k�I�J�J�J�
�"�"��	�
���&�!�!�!�!��Mrc#�K�|rv|d}|D]}|�|���|j5|j�|��ddd��n#1swxYwY~|���V�|�tdSdS)a~
    Iterate on the list *fs*, yielding finished futures one by one in
    reverse order.
    Before yielding a future, *waiter* is removed from its waiters
    and the future is removed from each set in the collection of sets
    *ref_collect*.

    The aim of this function is to avoid keeping stale references after
    the future is yielded and before the iterator resumes.
    ���N)�remover]ro�pop)rprr�ref_collectrk�futures_sets     r�_yield_finished_futuresr{�s�����
���r�F��&�	"�	"�K����q�!�!�!�!�
�\�	&�	&�
�J���f�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�
��f�f�h�h����
�����s�A�A�Ac	#�&K�|�|tj��z}t|��}t|��}t	|��5td�|D����}||z
}t|t��}ddd��n#1swxYwYt|��}	t|||f���Ed{V��|r�|�d}n=|tj��z
}|dkr!tdt|��|fz���|j
�|��|j5|j
}g|_
|j
���ddd��n#1swxYwY|���t||||f���Ed{V��|��|D];}|j5|j�|��ddd��n#1swxYwY�<dS#|D];}|j5|j�|��ddd��n#1swxYwY�<wxYw)anAn iterator over the given futures that yields each as it completes.

    Args:
        fs: The sequence of Futures (possibly created by different Executors) to
            iterate over.
        timeout: The maximum number of seconds to wait. If None, then there
            is no limit on the wait time.

    Returns:
        An iterator that yields the given Futures as they complete (finished or
        cancelled). If any given Futures are duplicated, they will be returned
        once.

    Raises:
        TimeoutError: If the entire result iterator could not be generated
            before the given timeout.
    Nc3�DK�|]}|jttfv�|V��dSr!rgris  rrlzas_completed.<locals>.<genexpr>�sE����C�C���8� 6��A�A�A��A�A�A�A�C�Cr)ryrz%d (of %d) futures unfinished)�time�	monotonicr<�lenrVrtr�listr{�TimeoutErrorr$�waitr9r%�clear�reverser]rorw)	rp�timeout�end_time�
total_futuresrrrr�wait_timeoutrks	         r�as_completedr��s�����$���T�^�-�-�-��	�R���B���G�G�M�	��	�	�@�@��C�C��C�C�C�C�C���x�-��,�R��?�?��@�@�@�@�@�@�@�@�@�@�@����@�@�@�@��H�~�~�H�*�*�8�V�8:�u�>�>�>�	>�	>�	>�	>�	>�	>�	>��	J���#���'�$�.�*:�*:�:���!�#�#�&�;���L�L�-�?9�9�:�:�:�
�L���l�+�+�+���
%�
%�!�2��*,��'���"�"�$�$�$�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%�
������.�x��<>��=�J�J�J�
J�
J�
J�
J�
J�
J�
J�'�	J�0�	*�	*�A���
*�
*��
�!�!�&�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��	*�	*���	*�	*�A���
*�
*��
�!�!�&�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��	*���sy�4B�B�B�#A>G�!(E�	G�E�G�E�3G�G�G	�	G	�H�H	�7H�H
�H�
H
�H�DoneAndNotDoneFuturesz
done not_donec��t|��}t|��5d�|D��}||z
}|tkr|rt||��cddd��S|tkr7|r5td�|D����rt||��cddd��St
|��t
|��krt||��cddd��St||��}ddd��n#1swxYwY|j�	|��|D];}|j
5|j�|��ddd��n#1swxYwY�<|�
|j��t|||z
��S)anWait for the futures in the given sequence to complete.

    Args:
        fs: The sequence of Futures (possibly created by different Executors) to
            wait upon.
        timeout: The maximum number of seconds to wait. If None, then there
            is no limit on the wait time.
        return_when: Indicates when this function should return. The options
            are:

            FIRST_COMPLETED - Return when any future finishes or is
                              cancelled.
            FIRST_EXCEPTION - Return when any future finishes by raising an
                              exception. If no future raises an exception
                              then it is equivalent to ALL_COMPLETED.
            ALL_COMPLETED -   Return when all futures finish or are cancelled.

    Returns:
        A named 2-tuple of sets. The first set, named 'done', contains the
        futures that completed (is finished or cancelled) before the wait
        completed. The second set, named 'not_done', contains uncompleted
        futures. Duplicate futures given to *fs* are removed and will be
        returned only once.
    c�<�h|]}|jttfv�|��Srrgris  r�	<setcomp>zwait.<locals>.<setcomp>"s7��F�F�F�a��h�#9�8�"D�D�D��D�D�DrNc3�jK�|].}|���s|����*|V��/dSr!)r�	exceptionris  rrlzwait.<locals>.<genexpr>(sP����G�G���+�+�-�-�G�,-�K�K�M�M�,E��,E�,E�,E�,E�G�Gr)r<rVrr�r�anyr�rtr$r�r]rorw�updater%)rpr�rq�done�not_donerrrks       rr�r�s���2

�R���B�	��	�	�>�>�F�F�2�F�F�F����9���?�*�*��*�(��x�8�8�>�>�>�>�>�>�>�>��_�,�,�$�,��G�G�d�G�G�G�G�G�
=�,�T�8�<�<�>�>�>�>�>�>�>�>��t�9�9��B�����(��x�8�8�>�>�>�>�>�>�>�>�-�R��=�=��>�>�>�>�>�>�>�>�>�>�>����>�>�>�>� �L���g����
�&�&��
�\�	&�	&�
�J���f�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&��	�K�K��'�(�(�(� ��r�D�y�1�1�1s5�.C4�5C4�/C4�C4�4C8�;C8�$E�E	�E	c��		|�|��|���~S#|���wxYw#~wxYwr!)�result�cancel)�futr�s  r�_result_or_cancelr�:sR���	��:�:�g�&�&��J�J�L�L�L�
�C��
�J�J�L�L�L�L�����
����s�-�A�A�A�A	c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
dd
�Zd�Zd�Zd�Zeej��ZdS)�Futurez5Represents the result of an asynchronous computation.c��tj��|_t|_d|_d|_g|_g|_dS)z8Initializes the future. Should not be called by clients.N)	r"�	Conditionr]rrh�_result�
_exceptionro�_done_callbacksr&s rr(zFuture.__init__Hs<��#�-�/�/��������������
�!����rc��|jD]9}	||���#t$rt�d|��Y�6wxYwdS)N�!exception calling callback for %r)r��	Exception�LOGGERr�)r'�callbacks  r�_invoke_callbackszFuture._invoke_callbacksQss���,�	L�	L�H�
L����������
L�
L�
L�� � �!D�d�K�K�K�K�K�
L����	L�	Ls��%?�?c��|j5|jtkr�|jrKd|jjt
|��t|j|jjjfzcddd��Sd|jjt
|��t|j|jjjfzcddd��Sd|jjt
|��t|jfzcddd��S#1swxYwYdS)Nz<%s at %#x state=%s raised %s>z <%s at %#x state=%s returned %s>z<%s at %#x state=%s>)	r]rhrr�r:rrZ�_STATE_TO_DESCRIPTION_MAPr�r&s r�__repr__zFuture.__repr__Xsh��
�_�	;�	;��{�h�&�&��?�9�;���/��4���1�$�+�>���1�:�	?<�<�	;�	;�	;�	;�	;�	;�	;�	;�>���/��4���1�$�+�>���.�7�	A9�9�	;�	;�	;�	;�	;�	;�	;�	;�*��N�+��t�H�H�,�T�[�9�-;�;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s�AC1�+>C1�6.C1�1C5�8C5c�B�|j5|jttfvr	ddd��dS|jtt
fvr	ddd��dSt|_|j���ddd��n#1swxYwY|���dS)z�Cancel the future if possible.

        Returns True if the future was cancelled, False otherwise. A future
        cannot be cancelled if it is running or has already completed.
        NFT)r]rhrrr	r
�
notify_allr�r&s rr�z
Future.cancells���_�	)�	)��{�w��1�1�1��	)�	)�	)�	)�	)�	)�	)�	)��{�y�*@�A�A�A��	)�	)�	)�	)�	)�	)�	)�	)�$�D�K��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � ��ts�B�B�%B�B�Bc�n�|j5|jttfvcddd��S#1swxYwYdS)z(Return True if the future was cancelled.N)r]rhr	r
r&s rrzFuture.cancelleds���
�_�	F�	F��;�9�.D�"E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�*�.�.c�d�|j5|jtkcddd��S#1swxYwYdS)z1Return True if the future is currently executing.N)r]rhrr&s rr
zFuture.running�sx��
�_�	*�	*��;�'�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s�%�)�)c�z�|j5|jtttfvcddd��S#1swxYwYdS)z>Return True if the future was cancelled or finished executing.N)r]rhr	r
rr&s rr�zFuture.done�s���
�_�	P�	P��;�9�.D�h�"O�O�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P�	P�	Ps�0�4�4c�<�|jr	|j�#d}wxYw|jSr!)r�r�r&s r�__get_resultzFuture.__get_result�s1���?�	 �
��o�%���������<�s��c�<�|j5|jtttfvr(|j�|��	ddd��dS	ddd��n#1swxYwY	||��dS#t$rt�	d|��YdSwxYw)a%Attaches a callable that will be called when the future finishes.

        Args:
            fn: A callable that will be called with this future as its only
                argument when the future completes or is cancelled. The callable
                will always be called by a thread in the same process in which
                it was added. If the future has already completed or been
                cancelled then the callable will be called immediately. These
                callables are called in the order that they were added.
        Nr�)
r]rhr	r
rr�r+r�r�r�)r'�fns  r�add_done_callbackzFuture.add_done_callback�s���_�	�	��{�9�.D�h�"O�O�O��$�+�+�B�/�/�/��	�	�	�	�	�	�	�	�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	H��B�t�H�H�H�H�H���	H�	H�	H����@�$�G�G�G�G�G�G�	H���s#�7A�A� A�%A2�2%B�BNc���	|j5|jttfvrt	���|jt
kr"|���cddd��d}S|j�|��|jttfvrt	���|jt
kr"|���cddd��d}St���#1swxYwY	d}dS#d}wxYw)aBReturn the result of the call that the future represents.

        Args:
            timeout: The number of seconds to wait for the result if the future
                isn't done. If None, then there is no limit on the wait time.

        Returns:
            The result of the call that the future represents.

        Raises:
            CancelledError: If the future was cancelled.
            TimeoutError: If the future didn't finish executing before the given
                timeout.
            Exception: If the call raised then that exception will be raised.
        N)	r]rhr	r
rr�_Future__get_resultr�r��r'r�s  rr�z
Future.result�sP�� 	���

)�

)��;�9�.D�"E�E�E�(�*�*�*��[�H�,�,��,�,�.�.�	

)�

)�

)�

)�

)�

)�

)� �D�D���$�$�W�-�-�-��;�9�.D�"E�E�E�(�*�*�*��[�H�,�,��,�,�.�.�

)�

)�

)�

)�

)�

)�

)� �D�D�'�.�.�(�

)�

)�

)�

)����

)�

)�

)�

)�

)� �D�D�D��4�D�K�K�K�KsB�C,�AC�C,�A C�?C,�C�C � C,�#C �$C,�,C0c��|j5|jttfvrt	���|jt
kr|jcddd��S|j�|��|jttfvrt	���|jt
kr|jcddd��St���#1swxYwYdS)aUReturn the exception raised by the call that the future represents.

        Args:
            timeout: The number of seconds to wait for the exception if the
                future isn't done. If None, then there is no limit on the wait
                time.

        Returns:
            The exception raised by the call that the future represents or None
            if the call completed without raising.

        Raises:
            CancelledError: If the future was cancelled.
            TimeoutError: If the future didn't finish executing before the given
                timeout.
        N)	r]rhr	r
rrr�r�r�r�s  rr�zFuture.exception�s��$�_�
	%�
	%��{�y�*@�A�A�A�$�&�&�&����(�(���	
	%�
	%�
	%�
	%�
	%�
	%�
	%�
	%�
�O� � ��)�)�)��{�y�*@�A�A�A�$�&�&�&����(�(���
	%�
	%�
	%�
	%�
	%�
	%�
	%�
	%�#�n�n�$�
	%�
	%�
	%�
	%����
	%�
	%�
	%�
	%�
	%�
	%s�:B=�AB=�/B=�=C�Cc��|j5|jtkr9t|_|jD]}|�|���	ddd��dS|jtkrt|_	ddd��dSt�	dt|��|j��td���#1swxYwYdS)a�Mark the future as running or process any cancel notifications.

        Should only be used by Executor implementations and unit tests.

        If the future has been cancelled (cancel() was called and returned
        True) then any threads waiting on the future completing (though calls
        to as_completed() or wait()) are notified and False is returned.

        If the future was not cancelled then it is put in the running state
        (future calls to running() will return True) and True is returned.

        This method should be called by Executor implementations before
        executing the work associated with this future. If this method returns
        False then the work should not be executed.

        Returns:
            False if the Future was cancelled, True otherwise.

        Raises:
            RuntimeError: if this method was already called or if set_result()
                or set_exception() was called.
        NFTz!Future %s in unexpected state: %szFuture in unexpected state)r]rhr	r
ror3rrr��criticalrZ�RuntimeError)r'rrs  r�set_running_or_notify_cancelz#Future.set_running_or_notify_cancel�sH��.�_�	A�	A��{�i�'�'�4���"�m�/�/�F��(�(��.�.�.�.��	A�	A�	A�	A�	A�	A�	A�	A����'�'�%����	A�	A�	A�	A�	A�	A�	A�	A���� C� "�4��� $��-�-�-�#�#?�@�@�@�	A�	A�	A�	A����	A�	A�	A�	A�	A�	As�=B9�B9�<=B9�9B=�B=c��|j5|jttthvr(td�|j|�����||_t|_|jD]}|�	|���|j�
��ddd��n#1swxYwY|���dS)z�Sets the return value of work associated with the future.

        Should only be used by Executor implementations and unit tests.
        �{}: {!r}N)r]rhr	r
rr�formatr�ror.r�r�)r'r�rrs   r�
set_resultzFuture.set_results���
�_�	)�	)��{�y�*@�(�K�K�K�'�
�(9�(9�$�+�t�(L�(L�M�M�M�!�D�L�"�D�K��-�
(�
(���!�!�$�'�'�'�'��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � � � ��BB#�#B'�*B'c��|j5|jttthvr(td�|j|�����||_t|_|jD]}|�	|���|j�
��ddd��n#1swxYwY|���dS)z�Sets the result of the future as being the given exception.

        Should only be used by Executor implementations and unit tests.
        r�N)r]rhr	r
rrr�r�ror1r�r�)r'r�rrs   r�
set_exceptionzFuture.set_exception(s���
�_�	)�	)��{�y�*@�(�K�K�K�'�
�(9�(9�$�+�t�(L�(L�M�M�M�'�D�O�"�D�K��-�
+�
+���$�$�T�*�*�*�*��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � � � r�r!)rrrrr(r�r�r�rr
r�r�r�r�r�r�r�r��classmethod�types�GenericAlias�__class_getitem__rrrr�r�Es������?�?�"�"�"�L�L�L�;�;�;�(���&F�F�F�
*�*�*�
P�P�P�
 � � �H�H�H�(!�!�!�!�F%�%�%�%�D&A�&A�&A�P
!�
!�
!�
!�
!�
!�$��E�$6�7�7���rr�c�@�eZdZdZd�Zddd�d�Zd
dd	�d
�Zd�Zd�ZdS)�ExecutorzCThis is an abstract base class for concrete asynchronous executors.c��t���)a Submits a callable to be executed with the given arguments.

        Schedules the callable to be executed as fn(*args, **kwargs) and returns
        a Future instance representing the execution of the callable.

        Returns:
            A Future representing the given call.
        )�NotImplementedError)r'r�rc�kwargss    r�submitzExecutor.submit<s��"�#�#�#rNrP)r��	chunksizec����������tj��z���fd�t|�D������fd�}|��S)a}Returns an iterator equivalent to map(fn, iter).

        Args:
            fn: A callable that will take as many arguments as there are
                passed iterables.
            timeout: The maximum number of seconds to wait. If None, then there
                is no limit on the wait time.
            chunksize: The size of the chunks the iterable will be broken into
                before being passed to a child process. This argument is only
                used by ProcessPoolExecutor; it is ignored by
                ThreadPoolExecutor.

        Returns:
            An iterator equivalent to: map(func, *iterables) but the calls may
            be evaluated out-of-order.

        Raises:
            TimeoutError: If the entire result iterator could not be generated
                before the given timeout.
            Exception: If fn(*args) raises for any values.
        Nc�,��g|]}�j�g|�R���Sr)r�)rjrcr�r's  ��r�
<listcomp>z Executor.map.<locals>.<listcomp>`s-���
A�
A�
A��k�d�k�"�$�t�$�$�$�
A�
A�
Arc3�h�K�	�����r`��$t������V�n8t�����tj��z
��V���`�D]}|����dS#�D]}|����wxYwr!)r�r�rxr~rr�)r-r�rpr�s ���r�result_iteratorz%Executor.map.<locals>.result_iteratords������
$��
�
�����W���/������9�9�9�9�9�9�/������(�T�^�EU�EU�:U�V�V�V�V�V��W�!�$�$�F��M�M�O�O�O�O�$�$��b�$�$�F��M�M�O�O�O�O�$���s�A6B�B1)r~r�zip)r'r�r�r��	iterablesr�r�rps```   @@r�mapzExecutor.mapGst�������,�����!1�!1�1�H�
A�
A�
A�
A�
A��i��
A�
A�
A��	$�	$�	$�	$�	$�	$�	$��� � � rTF)�cancel_futuresc��dS)a;Clean-up the resources associated with the Executor.

        It is safe to call this method several times. Otherwise, no other
        methods can be called after this one.

        Args:
            wait: If True then shutdown will not return until all running
                futures have finished executing and the resources used by the
                executor have been reclaimed.
            cancel_futures: If True then shutdown will cancel all pending
                futures. Futures that are completed or running will not be
                cancelled.
        Nr)r'r�r�s   r�shutdownzExecutor.shutdownss	��	
�rc��|Sr!rr&s rr_zExecutor.__enter__�s���rc�2�|�d���dS)NT)r�F)r�)r'�exc_type�exc_val�exc_tbs    rrdzExecutor.__exit__�s���
�
�4�
� � � ��ur)T)	rrrrr�r�r�r_rdrrrr�r�9s�������M�M�	$�	$�	$�+/�!�*!�*!�*!�*!�*!�X
�E�
�
�
�
�
� �������rr�c��eZdZdZdS)�BrokenExecutorzR
    Raised when a executor has become non-functional after a severe failure.
    Nrrrrr�r��s���������rr�r!))�
__author__�collections�loggingr"r~r�rrrrrrr	r
r�_FUTURE_STATESr��	getLoggerr�r�rrr�r�objectrr5rErKrVrtr{r��
namedtupler�r�r�r�r�r�r�rrr�<module>r�s-��2�
���������������������#��#���
��
���
���	�1������
������Y��Y�
�{��K��j���
��	�/�	0�	0��	�	�	�	�	�I�	�	�	�	�	�	�	�	�U�	�	�	���	�	�	�	�	��	�	�	�
-�
-�
-�
-�
-�f�
-�
-�
-����������,
�
�
�
�
�G�
�
�
�(�(�(�(�(�'�(�(�(�<(�(�(�(�(�f�(�(�(����,���,<*�<*�<*�<*�|/��.���2�2���}�02�02�02�02�f����r8�r8�r8�r8�r8�V�r8�r8�r8�hO�O�O�O�O�v�O�O�O�d�����\�����rfutures/__pycache__/process.cpython-311.opt-1.pyc000064400000111655152402271140015577 0ustar00�

.��_�B/$��:�dZdZddlZddlmZddlZddlZddlZddl	m
Z
ddlZddlZddl
mZddlZddlZddlmZej��ZdaGd	�d
��Zd�Zeje��dZd
ZGd�de��ZGd�d��Zd�ZGd�de��Z Gd�de��Z!Gd�de��Z"Gd�de
��Z#d�Z$d�Z%		d'd�Z&d(d�Z'Gd�d ej(��Z)da*da+d!�Z,d"�Z-Gd#�d$ej.��Z/Gd%�d&ej0��Z1dS))a-	Implements ProcessPoolExecutor.

The following diagram and text describe the data-flow through the system:

|======================= In-process =====================|== Out-of-process ==|

+----------+     +----------+       +--------+     +-----------+    +---------+
|          |  => | Work Ids |       |        |     | Call Q    |    | Process |
|          |     +----------+       |        |     +-----------+    |  Pool   |
|          |     | ...      |       |        |     | ...       |    +---------+
|          |     | 6        |    => |        |  => | 5, call() | => |         |
|          |     | 7        |       |        |     | ...       |    |         |
| Process  |     | ...      |       | Local  |     +-----------+    | Process |
|  Pool    |     +----------+       | Worker |                      |  #1..n  |
| Executor |                        | Thread |                      |         |
|          |     +----------- +     |        |     +-----------+    |         |
|          | <=> | Work Items | <=> |        | <=  | Result Q  | <= |         |
|          |     +------------+     |        |     +-----------+    |         |
|          |     | 6: call()  |     |        |     | ...       |    |         |
|          |     |    future  |     |        |     | 4, result |    |         |
|          |     | ...        |     |        |     | 3, except |    |         |
+----------+     +------------+     +--------+     +-----------+    +---------+

Executor.submit() called:
- creates a uniquely numbered _WorkItem and adds it to the "Work Items" dict
- adds the id of the _WorkItem to the "Work Ids" queue

Local worker thread:
- reads work ids from the "Work Ids" queue and looks up the corresponding
  WorkItem from the "Work Items" dict: if the work item has been cancelled then
  it is simply removed from the dict, otherwise it is repackaged as a
  _CallItem and put in the "Call Q". New _CallItems are put in the "Call Q"
  until "Call Q" is full. NOTE: the size of the "Call Q" is kept small because
  calls placed in the "Call Q" can no longer be cancelled with Future.cancel().
- reads _ResultItems from "Result Q", updates the future stored in the
  "Work Items" dict and deletes the dict entry

Process #1..n:
- reads _CallItems from "Call Q", executes the calls, and puts the resulting
  _ResultItems in "Result Q"
z"Brian Quinlan (brian@sweetapp.com)�N)�_base)�Queue)�partial)�format_exceptionFc�&�eZdZd�Zd�Zd�Zd�ZdS)�
_ThreadWakeupc�X�d|_tjd���\|_|_dS)NF)�duplex)�_closed�mp�Pipe�_reader�_writer��selfs �E/opt/alt/python-internal/lib/python3.11/concurrent/futures/process.py�__init__z_ThreadWakeup.__init__Cs(�����%'�W�E�%:�%:�%:�"���d�l�l�l�c��|js;d|_|j���|j���dSdS�NT)rr�closerrs rrz_ThreadWakeup.closeGsM���|�	!��D�L��L��� � � ��L��� � � � � �	!�	!rc�L�|js|j�d��dSdS)Nr)rr�
send_bytesrs r�wakeupz_ThreadWakeup.wakeupRs2���|�	)��L�#�#�C�(�(�(�(�(�	)�	)rc��|jsM|j���r6|j���|j����2dSdSdS�N)rr�poll�
recv_bytesrs r�clearz_ThreadWakeup.clearVsl���|�	*��,�#�#�%�%�
*���'�'�)�)�)��,�#�#�%�%�
*�
*�
*�	*�	*�
*�
*rN)�__name__�
__module__�__qualname__rrrr�rrrrBsP������;�;�;�	!�	!�	!�)�)�)�*�*�*�*�*rrc���datt�����}|D]\}}|����|D]\}}|����dSr)�_global_shutdown�list�_threads_wakeups�itemsr�join)r(�_�
thread_wakeup�ts    r�_python_exitr-\sw�����!�'�'�)�)�*�*�E�!�����=�������������1�	��������r��=c��eZdZd�Zd�ZdS)�_RemoteTracebackc��||_dSr��tb)rr4s  rrz_RemoteTraceback.__init__|s
������rc��|jSrr3rs r�__str__z_RemoteTraceback.__str__~s	���w�rN)r r!r"rr6r#rrr1r1{s2�������������rr1c��eZdZd�Zd�ZdS)�_ExceptionWithTracebackc��d�tt|��||����}||_d|j_d|z|_dS)N�z

"""
%s""")r)r�type�exc�
__traceback__r4)rr<r4s   rrz _ExceptionWithTraceback.__init__�sI��
�W�W�%�d�3�i�i��b�9�9�
:�
:�����"&���� �2�%����rc�,�t|j|jffSr)�_rebuild_excr<r4rs r�
__reduce__z"_ExceptionWithTraceback.__reduce__�s���d�h���0�0�0rN)r r!r"rr@r#rrr8r8�s2������&�&�&�1�1�1�1�1rr8c�.�t|��|_|Sr)r1�	__cause__)r<r4s  rr?r?�s��$�R�(�(�C�M��Jrc��eZdZd�ZdS)�	_WorkItemc�>�||_||_||_||_dSr)�future�fn�args�kwargs)rrFrGrHrIs     rrz_WorkItem.__init__�s"����������	�����rN�r r!r"rr#rrrDrD��#����������rrDc��eZdZdd�ZdS)�_ResultItemNc�>�||_||_||_||_dSr)�work_id�	exception�result�exit_pid)rrOrPrQrRs     rrz_ResultItem.__init__�s"�����"������ ��
�
�
r�NNNrJr#rrrMrM�s(������!�!�!�!�!�!rrMc��eZdZd�ZdS)�	_CallItemc�>�||_||_||_||_dSr)rOrGrHrI)rrOrGrHrIs     rrz_CallItem.__init__�s"����������	�����rNrJr#rrrUrU�rKrrUc�.��eZdZdZd�fd�	Z�fd�Z�xZS)�
_SafeQueuez=Safe Queue set exception to the future object linked to a jobrc�x��||_||_||_t���||���dS)N)�ctx)�pending_work_items�
shutdown_lockr+�superr)r�max_sizerZr[r\r+�	__class__s      �rrz_SafeQueue.__init__�s>���"4���*���*���
������s��+�+�+�+�+rc� ��t|t��r�tt|��||j��}td�d�|������|_|j	�
|jd��}|j5|j
���ddd��n#1swxYwY|�|j�|��dSdSt#���||��dS)Nz

"""
{}"""r:)�
isinstancerUrr;r=r1�formatr)rBr[�poprOr\r+rrF�
set_exceptionr]�_on_queue_feeder_error)r�e�objr4�	work_itemr_s     �rrez!_SafeQueue._on_queue_feeder_error�s1����c�9�%�%�	3�!�$�q�'�'�1�a�o�>�>�B�*�>�+@�+@�������+M�+M�N�N�A�K��/�3�3�C�K��F�F�I��#�
,�
,��"�)�)�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,�
�$�� �.�.�q�1�1�1�1�1�%�$�
�G�G�*�*�1�c�2�2�2�2�2s�C�C�C)r)r r!r"�__doc__rre�
__classcell__�r_s@rrXrX�s\�������G�G�,�,�,�,�,�,�
3�
3�
3�
3�
3�
3�
3�
3�
3rrXc'�pK�t|�}	ttj||����}|sdS|V��+)z, Iterates over zip()ed iterables in chunks. TN)�zip�tuple�	itertools�islice)�	chunksize�	iterables�it�chunks    r�_get_chunksru�sI����	�i��B���i�&�r�9�5�5�6�6���	��F�����	rc� ���fd�|D��S)z� Processes a chunk of an iterable passed to map.

    Runs the function passed to map() on a chunk of the
    iterable passed to map.

    This function is run in a separate process.

    c���g|]}�|���Sr#r#)�.0rHrGs  �r�
<listcomp>z"_process_chunk.<locals>.<listcomp>�s���(�(�(�$�B�B��I�(�(�(rr#)rGrts` r�_process_chunkrz�s���)�(�(�(�%�(�(�(�(rc��	|�t||||�����dS#t$rE}t||j��}|�t|||�����Yd}~dSd}~wwxYw)z.Safely send back the given result or exception)rQrPrR�rPrRN)�putrM�
BaseExceptionr8r=)�result_queuerOrQrPrRrfr<s       r�_sendback_resultr��s���9�����W�V�/8�8�M�M�M�	N�	N�	N�	N�	N���9�9�9�%�a���9�9������W��.6�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�����9���s�&*�
A9�:A4�4A9c�:�|�9	||�n2#t$r%tj�dd���YdSwxYwd}d}	|�d���}|�(|�t
j����dS|�|dz
}||krt
j��}	|j|j	i|j
��}t||j||���~nD#t$r7}	t|	|	j��}
t||j|
|�	��Yd}	~	nd}	~	wwxYw~|�dS��)
a�Evaluates calls from call_queue and places the results in result_queue.

    This worker is run in a separate process.

    Args:
        call_queue: A ctx.Queue of _CallItems that will be read and
            evaluated by the worker.
        result_queue: A ctx.Queue of _ResultItems that will written
            to by the worker.
        initializer: A callable initializer, or None
        initargs: A tuple of args for the initializer
    NzException in initializer:T)�exc_infor��blockr.)rQrRr|)r~r�LOGGER�critical�getr}�os�getpidrGrHrIr�rOr8r=)�
call_queuer�initializer�initargs�	max_tasks�	num_tasksrR�	call_item�rrfr<s           r�_process_workerr��s�����	��K��"�"�"���	�	�	��L�!�!�"=��!�M�M�M�
�F�F�		����
�I��H���N�N��N�.�.�	������R�Y�[�[�)�)�)��F�� ���N�I��I�%�%��9�;�;��		��	��i�n�A�	�0@�A�A�A�
�\�9�+<�Q�&.�
0�
0�
0�
0�����	0�	0�	0�)�!�Q�_�=�=�C��\�9�+<��&.�
0�
0�
0�
0�
0�
0�
0�
0�
0�����	0����
����F�9s$�
�+9�9�"C�
D�-D�Dc�^��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Z�xZS)
�_ExecutorManagerThreadatManages the communication between this process and the worker processes.

    The manager is run in a local thread.

    Args:
        executor: A reference to the ProcessPoolExecutor that owns
            this thread. A weakref will be own by the manager as well as
            references to internal objects used to introspect the state of
            the executor.
    c�\��|j|_|j|_|j|jfd�}t	j||��|_|j|_|j	|_
|j|_|j
|_|j|_|j|_t'�����dS)Nc��tj�d��|5|���ddd��dS#1swxYwYdS)Nz?Executor collected: triggering callback for QueueManager wakeup)r�util�debugr)r*r+r\s   r�
weakref_cbz3_ExecutorManagerThread.__init__.<locals>.weakref_cb1s���
�G�M�M�1�
2�
2�
2��
'�
'��$�$�&�&�&�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'�
'�
's�A�A�A)�_executor_manager_thread_wakeupr+�_shutdown_lockr\�weakref�ref�executor_reference�
_processes�	processes�_call_queuer��
_result_queuer�	_work_ids�work_ids_queue�_max_tasks_per_child�max_tasks_per_child�_pending_work_itemsr[r]r)r�executorr�r_s   �rrz_ExecutorManagerThread.__init__#s����
&�E���%�4���&*�%7�%)�%7�	'�	'�	'�	'�#*�+�h�
�"C�"C���"�,���#�.���%�2���'�0���$,�#@�� �#+�">���
���������rc��	|���|���\}}}|r|�|��dS|��|�|��|jdu}|r3|j�|j��}|���~|���x}rP|r4|j	5|�
��ddd��n#1swxYwYn|j���~|�
��rE|���|���|js|���dS��\r)�add_call_item_to_queue�wait_result_broken_or_wakeup�terminate_broken�process_result_itemrRr�rcr)r�r\�_adjust_process_count�_idle_worker_semaphore�release�is_shutting_down�flag_executor_shutting_downr[�join_executor_internals)r�result_item�	is_broken�cause�process_exited�pr�s       r�runz_ExecutorManagerThread.runRs���(	��'�'�)�)�)�,0�,M�,M�,O�,O�)�K��E��
��%�%�e�,�,�,����&��(�(��5�5�5�!,�!5�T�!A��!����*�*�;�+?�@�@�A��F�F�H�H�H� �#�6�6�8�8�8�8�!�%�B�!�/�=�=�$�:�:�<�<�<�=�=�=�=�=�=�=�=�=�=�=����=�=�=�=��!�7�?�?�A�A�A� ��$�$�&�&�
��0�0�2�2�2�
�+�+�-�-�-��.���0�0�2�2�2��F�Q(	s�<C�C!�$C!c�v�	|j���rdS	|j�d���}|j|}|j���r<|j�t||j	|j
|j��d���n|j|=��#tj
$rYdSwxYw��)NTFr�)r��fullr�r�r[rF�set_running_or_notify_cancelr}rUrGrHrI�queue�Empty)rrOrhs   rr�z-_ExecutorManagerThread.add_call_item_to_queues���	���#�#�%�%�
���
��-�1�1��1�>�>��!�3�G�<�	��#�@�@�B�B���O�'�'�	�'�2;�,�2;�.�2;�2B�)D�)D�/3�	(�4�4�4�4��/��8����;�
�
�
����
����	s�B$�$B7�6B7c���|jj}|jj}||g}d�t|j�����D��}tj�||z��}d}d}d}||vrR	|�	��}d}n@#t$r-}	tt|	��|	|	j
��}Yd}	~	nd}	~	wwxYw||vrd}|j���|||fS)Nc��g|]	}|j��
Sr#)�sentinel�rxr�s  rryzG_ExecutorManagerThread.wait_result_broken_or_wakeup.<locals>.<listcomp>�s��N�N�N�1�A�J�N�N�NrTF)rrr+r&r��valuesr�
connection�wait�recvr~rr;r=r)
r�
result_reader�
wakeup_reader�readers�worker_sentinels�readyr�r�r�rfs
          rr�z3_ExecutorManagerThread.wait_result_broken_or_wakeup�s���)�1�
��*�2�
� �-�0��N�N��T�^�5J�5J�5L�5L�0M�0M�N�N�N���
�"�"�7�-=�#=�>�>�����	����E�!�!�
F�+�0�0�2�2��!�	�	�� �
F�
F�
F�(��a���!�Q�_�E�E�����������
F�����e�
#�
#��I�	
�� � �"�"�"��I�u�,�,s�:B�
C�#C�Cc��t|t��rM|j�|��}|���|js|���dSdS|j�|jd��}|�I|jr!|j	�
|j��dS|j	�|j��dSdSr)
ra�intr�rcr)r�r[rOrPrFrd�
set_resultrQ)rr�r�rhs    rr�z*_ExecutorManagerThread.process_result_item�s����k�3�'�'�	D���"�"�;�/�/�A�
�F�F�H�H�H��>�
��,�,�.�.�.���
�
�
�/�3�3�K�4G��N�N�I��$��(�D��$�2�2�;�3H�I�I�I�I�I��$�/�/��0B�C�C�C�C�C�	%�$rc�N�|���}tp
|dup|jSr)r�r%�_shutdown_thread)rr�s  rr�z'_ExecutorManagerThread.is_shutting_down�s4���*�*�,�,��
!�-�H��$4�-��,�	.rc��|���}|�d|_d|_d}td��}|�+t	dd�|���d���|_|j���D] \}}|j	�
|��~�!|j���|j�
��D]}|����|jj���t$jdkr|jj���|���dS)NzKA child process terminated abruptly, the process pool is not usable anymoreTz^A process in the process pool was terminated abruptly while the future was running or pending.z
'''
r:z'''�win32)r��_brokenr��BrokenProcessPoolr1r)rBr[r(rFrdrr�r��	terminater�rr�sys�platformrr�)rr�r��bperOrhr�s       rr�z'_ExecutorManagerThread.terminate_broken�sX���*�*�,�,����!1�H��)-�H�%��H� �!6�7�7����,�-�"�'�'�%�.�.�-�-�-�/�/�C�M�#'�"9�"?�"?�"A�"A�	�	��G�Y���*�*�3�/�/�/��	���%�%�'�'�'���&�&�(�(�	�	�A�
�K�K�M�M�M�M�	
���%�%�'�'�'��<�7�"�"��O�#�)�)�+�+�+�	
�$�$�&�&�&�&�&rc�T�|���}|��d|_|jr�i}|j���D]#\}}|j���s|||<�$||_		|j���n#tj
$rYnwxYw�1d|_dSdSdS)NTF)r�r��_cancel_pending_futuresr[r(rF�cancelr��
get_nowaitr�r�)rr��new_pending_work_itemsrOrhs     rr�z2_ExecutorManagerThread.flag_executor_shutting_down	s����*�*�,�,����(,�H�%��/�
9�*,�&�*.�*A�*G�*G�*I�*I�D�D�&�G�Y�$�+�2�2�4�4�D�:C�.�w�7��*@��'����+�6�6�8�8�8�8�� �;�����������49��0�0�0�) ��
9�
9s�-B�B�Bc�L�|���}d}||kr�|���dkrmt||z
��D]8}	|j�d��|dz
}�##tj$rYnwxYw||kr|���dk�idSdSdSdS)Nrr.)�get_n_children_alive�ranger��
put_nowaitr��Full)r�n_children_to_stop�n_sentinels_sent�is    r�shutdown_workersz'_ExecutorManagerThread.shutdown_workers#s���!�6�6�8�8���� �"4�4�4��-�-�/�/�!�3�3��-�0@�@�A�A�
�
����O�.�.�t�4�4�4�$��)�$�$���z�����E�E�����
 �"4�4�4��-�-�/�/�!�3�3�3�3�5�4�3�3�5�4s�
A*�*A=�<A=c�b�|���|j���|j���|j5|j���ddd��n#1swxYwY|j���D]}|����dSr)	r�r�r�join_threadr\r+r�r�r)�rr�s  rr�z._ExecutorManagerThread.join_executor_internals1s������������������#�#�%�%�%�
�
�	'�	'���$�$�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'���&�&�(�(�	�	�A�
�F�F�H�H�H�H�	�	s�A4�4A8�;A8c�b�td�|j���D����S)Nc3�>K�|]}|���V��dSr)�is_aliver�s  r�	<genexpr>z>_ExecutorManagerThread.get_n_children_alive.<locals>.<genexpr>?s*����A�A�A�1�:�:�<�<�A�A�A�A�A�Ar)�sumr�r�rs rr�z+_ExecutorManagerThread.get_n_children_alive=s-���A�A���)>�)>�)@�)@�A�A�A�A�A�Ar)r r!r"rirr�r�r�r�r�r�r�r�r�r�rjrks@rr�r�s��������	�	�-�-�-�-�-�^+�+�+�Z���.!-�!-�!-�FD�D�D�..�.�.�-'�-'�-'�^9�9�9�4���
�
�
�B�B�B�B�B�B�Brr�c�L�trtrtt���da	ddl}n$#t$rdatt���wxYw	tjd��}n#ttf$rYdSwxYw|dkrdS|dkrdSd|zatt���)NTrzxThis Python build lacks multiprocessing.synchronize, usually due to named semaphores being unavailable on this platform.�SC_SEM_NSEMS_MAX����z@system provides too few semaphores (%d available, 256 necessary))	�_system_limits_checked�_system_limited�NotImplementedError�multiprocessing.synchronize�ImportErrorr��sysconf�AttributeError�
ValueError)�multiprocessing�	nsems_maxs  r�_check_system_limitsr�Fs����7��	7�%�o�6�6�6�!��3�*�*�*�*�*���3�3�3�
F�	�"�/�2�2�2�3������J�1�2�2�	�	���J�'������������B���	���C���	��4�6?�@�O�
�o�
.�
.�.s�+�!A�A%�%A:�9A:c#�pK�|D]0}|���|r|���V�|��1dS)z�
    Specialized implementation of itertools.chain.from_iterable.
    Each item in *iterable* should be a list.  This function is
    careful not to keep references to yielded objects.
    N)�reverserc)�iterable�elements  r�_chain_from_iterable_of_listsrfsX����� � ���������	 ��+�+�-�-�����	 �� � rc��eZdZdZdS)r�zy
    Raised when a process in a ProcessPoolExecutor terminated abruptly
    while a future was in the running state.
    N)r r!r"rir#rrr�r�rs���������rr�c���eZdZ		ddd�d�Zd�Zd�Zd�Zd�Zd	�Ze	j
jje_dd
d��fd�
Zddd�d�Z
e	j
j
je
_�xZS)�ProcessPoolExecutorNr#)r�c��t��|�Jtj��pd|_tjdkrt
t|j��|_nN|dkrtd���tjdkr"|tkrtdt�����||_|�*|�tj
d��}ntj
��}||_|j�d�	��d
k|_
|�t|��std���||_||_|�gt%|t&��std���|dkrtd
���|j�d�	��d
krtd���||_d|_i|_d|_t1j��|_t1jd��|_d|_d|_i|_d|_ tC��|_"|jtFz}tI||j|j|j|j"���|_%d|j%_&|�'��|_(tSj*��|_+dS)aHInitializes a new ProcessPoolExecutor instance.

        Args:
            max_workers: The maximum number of processes that can be used to
                execute the given calls. If None or not given then as many
                worker processes will be created as the machine has processors.
            mp_context: A multiprocessing context to launch the workers. This
                object should provide SimpleQueue, Queue and Process. Useful
                to allow specific multiprocessing start methods.
            initializer: A callable used to initialize worker processes.
            initargs: A tuple of arguments to pass to the initializer.
            max_tasks_per_child: The maximum number of tasks a worker process
                can complete before it will exit and be replaced with a fresh
                worker process. The default of None means worker process will
                live as long as the executor. Requires a non-'fork' mp_context
                start method. When given, we default to using 'spawn' if no
                mp_context is supplied.
        Nr.r�rz"max_workers must be greater than 0zmax_workers must be <= �spawnF)�
allow_none�forkzinitializer must be a callablez&max_tasks_per_child must be an integerz max_tasks_per_child must be >= 1zpmax_tasks_per_child is incompatible with the 'fork' multiprocessing start method; supply a different mp_context.)r^rZr[r\r+T),r�r��	cpu_count�_max_workersr�r��min�_MAX_WINDOWS_WORKERSr�r�get_context�_mp_context�get_start_method�#_safe_to_dynamically_spawn_children�callable�	TypeError�_initializer�	_initargsrar�r��_executor_manager_threadr�r��	threading�Lockr��	Semaphorer�r��_queue_countr�r�rr��EXTRA_QUEUED_CALLSrXr��
_ignore_epipe�SimpleQueuer�r�rr�)r�max_workers�
mp_contextr�r�r��
queue_sizes       rrzProcessPoolExecutor.__init__zs���(	������ "���� 3�!�D���|�w�&�&�$'�(<�(,�(9�%;�%;��!���a��� �!E�F�F�F��,�'�)�)��2�2�2� �D�.B�D�D�F�F�F�!,�D����"�.��^�G�4�4�
�
��^�-�-�
�%���� �1�1�U�1�C�C�v�M�	
�0��"�8�K�+@�+@�"��<�=�=�=�'���!����*��1�3�7�7�
E�� H�I�I�I�$��)�)� �!C�D�D�D���0�0�E�0�B�B�f�L�L� �"C�D�D�D�%8��!�)-��%����!&���'�n�.�.���&/�&9�!�&<�&<��#�������#%�� �',��$�0=����,��&�);�;�
�%��T�%5�#�7��-��>�	@�@�@���*.���&�'�3�3�5�5����������rc���|j�^|js|���t|��|_|j���|jt|j<dSdSr)rr�_launch_processesr��startr�r'rs r�_start_executor_manager_threadz2ProcessPoolExecutor._start_executor_manager_thread�sn���(�0��;�
)��&�&�(�(�(�,B�4�,H�,H�D�)��)�/�/�1�1�1��4�
�T�:�;�;�;�
1�0rc��|j�d���rdSt|j��}||jkr|���dSdS)NF)�blocking)r��acquire�lenr�r
�_spawn_process)r�
process_counts  rr�z)ProcessPoolExecutor._adjust_process_count�sb���&�.�.��.�>�>�	��F��D�O�,�,�
��4�,�,�,�
���!�!�!�!�!�-�,rc��tt|j��|j��D]}|����dSr)r�r'r�r
r()rr*s  rr!z%ProcessPoolExecutor._launch_processessI��
�s�4�?�+�+�T�->�?�?�	"�	"�A����!�!�!�!�	"�	"rc���|j�t|j|j|j|j|jf���}|���||j	|j
<dS)N)�targetrH)r�Processr�r�r�rrr�r"r��pidr�s  rr(z"ProcessPoolExecutor._spawn_process	sg����$�$�"��"��$��#��.��+�	-�
%�
.�
.��	
���	�	�	�!"�������rc�,�|j5|jrt|j���|jrt	d���t
rt	d���t
j��}t||||��}||j	|j
<|j�|j
��|xj
dz
c_
|j
���|jr|���|���|cddd��S#1swxYwYdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdownr.)r�r�r�r��RuntimeErrorr%r�FuturerDr�rr�r}r�rrr�r#)rrGrHrI�f�ws      r�submitzProcessPoolExecutor.submitsg��
�
 �	�	��|�
6�'���5�5�5��$�
Q�"�#O�P�P�P��
;�"�$:�;�;�;�����A��!�R��v�.�.�A�:;�D�$�T�%6�7��N���t�0�1�1�1�����"����0�7�7�9�9�9��7�
-��*�*�,�,�,��/�/�1�1�1��+	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�C4D	�	D
�D
r.)�timeoutrqc����|dkrtd���t���tt|��t|d|i�|���}t
|��S)ajReturns an iterator equivalent to map(fn, iter).

        Args:
            fn: A callable that will take as many arguments as there are
                passed iterables.
            timeout: The maximum number of seconds to wait. If None, then there
                is no limit on the wait time.
            chunksize: If greater than one, the iterables will be chopped into
                chunks of size chunksize and submitted to the process pool.
                If set to one, the items in the list will be sent one at a time.

        Returns:
            An iterator equivalent to: map(func, *iterables) but the calls may
            be evaluated out-of-order.

        Raises:
            TimeoutError: If the entire result iterator could not be generated
                before the given timeout.
            Exception: If fn(*args) raises for any values.
        r.zchunksize must be >= 1.rq)r5)r�r]�maprrzrur)rrGr5rqrr�resultsr_s      �rr7zProcessPoolExecutor.map-sh���*�q�=�=��6�7�7�7��'�'�+�+�g�n�b�9�9�)�9�J�	�J�J�&-��/�/��-�W�5�5�5rTF)�cancel_futuresc�n�|j5||_d|_|j�|j���ddd��n#1swxYwY|j�|r|j���d|_d|_|j�|r|j�	��d|_d|_
d|_dSr)r�r�r�r�rrr)r�r�rr�)rr�r9s   r�shutdownzProcessPoolExecutor.shutdownJs��
�
 �	>�	>�+9�D�(�$(�D�!��3�?��4�;�;�=�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>��(�4��4��)�.�.�0�0�0�)-��%������)�d�)���$�$�&�&�&�!������/3��,�,�,s�/A�A�
A)NNNr#)T)r r!r"rr#r�r!r(r4r�Executorrir7r;rjrks@rrrys��������48�,.�l'�GK�l'�l'�l'�l'�l'�\5�5�5�
"�
"�
"�"�"�"�	#�	#�	#����.�^�*�2�F�N�*.�!�6�6�6�6�6�6�6�:4�E�4�4�4�4�4�(�~�.�6�H�����rrrSr)2ri�
__author__r��concurrent.futuresrr�r�r�multiprocessing.connection�multiprocessing.queuesrrr��	functoolsrror��	tracebackr�WeakKeyDictionaryr'r%rr-�_register_atexitrr�	Exceptionr1r8r?�objectrDrMrUrXrurzr�r��Threadr�r�r�r�r�BrokenExecutorr�r<rr#rr�<module>rIsY��(�(�T2�
�	�	�	�	�$�$�$�$�$�$���������!�!�!�!�(�(�(�(�(�(�������������������
�
�
�
�&�&�&�&�&�&�-�7�,�.�.����*�*�*�*�*�*�*�*�4����	��<�(�(�(����������y����	1�	1�	1�	1�	1�	1�	1�	1�������������!�!�!�!�!�&�!�!�!����������3�3�3�3�3��3�3�3�2���	)�	)�	)�DH�"�	9�	9�	9�	9�3�3�3�3�lhB�hB�hB�hB�hB�Y�-�hB�hB�hB�V	����/�/�/�@	 �	 �	 �������,����e7�e7�e7�e7�e7�%�.�e7�e7�e7�e7�e7rfutures/__pycache__/thread.cpython-311.opt-2.pyc000064400000024456152402271140015373 0ustar00�

7����'r���x�	dZddlmZddlZddlZddlZddlZddlZddlZej	��Z
daej��Z
d�Zeje��eed��r"eje
je
je
j���Gd�d	e��Zd
�ZGd�dej��ZGd
�dej��ZdS)z"Brian Quinlan (brian@sweetapp.com)�)�_baseNFc��t5daddd��n#1swxYwYtt�����}|D]\}}|�d���|D]\}}|����dS�NT)�_global_shutdown_lock�	_shutdown�list�_threads_queues�items�put�join)r
�t�qs   �D/opt/alt/python-internal/lib/python3.11/concurrent/futures/thread.py�_python_exitrs���	����	���������������������&�&�(�(�)�)�E������1�	���d����������1�	��������s����register_at_fork)�before�after_in_child�after_in_parentc�:�eZdZd�Zd�Zeej��ZdS)�	_WorkItemc�>�||_||_||_||_dS�N)�future�fn�args�kwargs)�selfrrrrs     r�__init__z_WorkItem.__init__/s"����������	������c��|j���sdS	|j|ji|j��}|j�|��dS#t$r'}|j�|��d}Yd}~dSd}~wwxYwr)r�set_running_or_notify_cancelrrr�
set_result�
BaseException�
set_exception)r�result�excs   r�runz
_WorkItem.run5s����{�7�7�9�9�	��F�	+��T�W�d�i�7�4�;�7�7�F�
�K�"�"�6�*�*�*�*�*���	�	�	��K�%�%�c�*�*�*��D�D�D�D�D�D�D�����	���s�A�
B�A<�<BN)	�__name__�
__module__�__qualname__rr'�classmethod�types�GenericAlias�__class_getitem__�rrrr.sC���������+�+�+�$��E�$6�7�7���rrc�@�|�Y	||�nR#t$rEtj�dd���|��}|�|���YdSwxYw		|�d���}|�<|���~|��}|�|j���~�U|��}ts	|�|j	r |�d|_	|�
d��dS~��#t$r%tj�dd���YdSwxYw)NzException in initializer:T)�exc_info)�blockzException in worker)r#r�LOGGER�critical�_initializer_failed�getr'�_idle_semaphore�releaserr)�executor_reference�
work_queue�initializer�initargs�executor�	work_items      r�_workerr?Es�����	��K��"�"�"���	�	�	��L�!�!�"=��!�M�M�M�)�)�+�+�H��#��,�,�.�.�.��F�F�	����D�	�"���T��2�2�I��$��
�
�����.�-�/�/���'��,�4�4�6�6�6���)�)�+�+�H�
�
�H�,��0B�,��'�)-�H�&����t�$�$�$����7	��8�D�D�D�
����3�d��C�C�C�C�C�C�D���s)�
�AA�A�B
C.�,C.�.+D�Dc��eZdZdS)�BrokenThreadPoolN)r(r)r*r/rrrArAps�������rrAc��eZdZej��jZ		dd�Zd�Ze	j
jje_d�Zd�Z
d
d	d
�d�Ze	j
jje_dS)�ThreadPoolExecutorN�r/c��	|�&tdtj��pddz��}|dkrtd���|�t	|��std���||_tj��|_	tjd��|_t��|_d|_d|_tj��|_|pd|���z|_||_||_dS)	N� ��rz"max_workers must be greater than 0zinitializer must be a callableFzThreadPoolExecutor-%d)�min�os�	cpu_count�
ValueError�callable�	TypeError�_max_workers�queue�SimpleQueue�_work_queue�	threading�	Semaphorer7�set�_threads�_brokenr�Lock�_shutdown_lock�_counter�_thread_name_prefix�_initializer�	_initargs)r�max_workers�thread_name_prefixr;r<s     rrzThreadPoolExecutor.__init__{s���	����b�2�<�>�>�#6�Q�!�";�<�<�K��!����A�B�B�B��"�8�K�+@�+@�"��<�=�=�=�'��� �,�.�.���(�2�1�5�5�������
�������'�n�.�.���$6�%P�%<�t�}�}���%N�	
� �'���!����rc���|j5t5|jrt|j���|jrtd���trtd���t
j��}t||||��}|j	�
|��|���|cddd��cddd��S#1swxYwYddd��dS#1swxYwYdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdown)rYrrWrAr�RuntimeErrorr�FuturerrRr�_adjust_thread_count)rrrr�f�ws      r�submitzThreadPoolExecutor.submit�s���
�
 �	�	�"7�	�	��|�
5�&�t�|�4�4�4��~�
Q�"�#O�P�P�P��
;�"�$:�;�;�;�����A��!�R��v�.�.�A��� � ��#�#�#��%�%�'�'�'��	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s5�C�BC�,C�C		�	C�C		�
C�C!�$C!c��|j�d���rdS|jfd�}t|j��}||jkr�d|jp||fz}tj|ttj||��|j|j|j
f���}|���|j�|��|jt |<dSdS)Nr)�timeoutc�0�|�d��dSr)r)�_rs  r�
weakref_cbz;ThreadPoolExecutor._adjust_thread_count.<locals>.weakref_cb�s��
�E�E�$�K�K�K�K�Krz%s_%d)�name�targetr)r7�acquirerR�lenrVrOr[rS�Threadr?�weakref�refr\r]�start�addr	)rrk�num_threads�thread_namer
s     rrcz'ThreadPoolExecutor._adjust_thread_count�s�����'�'��'�2�2�	��F�!�,�	�	�	�	��$�-�(�(����*�*�*�!�T�%=�%E��%0�%2�2�K�� �k�'�'.�{�4��'D�'D�'+�'7�'+�'8�'+�~�'7�8�8�8�A�

�G�G�I�I�I��M���a� � � �!%�!1�O�A����+�*rc��|j5d|_		|j���}n#tj$rYn3wxYw|�,|j�t|j�����_	ddd��dS#1swxYwYdS)NzBA thread initializer failed, the thread pool is not usable anymore)	rYrWrR�
get_nowaitrP�Emptyrr$rA)rr>s  rr5z&ThreadPoolExecutor._initializer_failed�s��
�
 �
	S�
	S�4�D�L�
S�� $� 0� ;� ;� =� =�I�I���{�����E������(��$�2�2�3C�D�L�3Q�3Q�R�R�R�

S��
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S����
	S�
	S�
	S�
	S�
	S�
	Ss,�	A>�,�A>�>�A>�>�2A>�>B�BTF)�cancel_futuresc�h�|j5d|_|rM		|j���}n#tj$rYn wxYw|�|j����L|j�d��ddd��n#1swxYwY|r|j	D]}|�
���dSdSr)rYrrRrxrPryr�cancelrrVr)r�waitrzr>r
s     r�shutdownzThreadPoolExecutor.shutdown�s(��
�
 �	'�	'�!�D�N��	
2�2��$(�$4�$?�$?�$A�$A�	�	�� �;���������� �,�!�(�/�/�1�1�1�
2�
�� � ��&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'� �	��]�
�
���������	�	�
�
s/�B�.�B�A�B�A�9B�B	�B	)NrDNr/)T)r(r)r*�	itertools�count�__next__rZrrfr�Executor�__doc__rcr5r~r/rrrCrCvs��������y�� � �)�H�<>�,.�$"�$"�$"�$"�L���"�^�*�2�F�N�2�2�2�.S�S�S��E������(�~�.�6�H���rrC)�
__author__�concurrent.futuresrrrPrSr,rqrJ�WeakKeyDictionaryr	rrXrr�_register_atexit�hasattrrrn�_at_fork_reinitr8�objectrr?�BrokenExecutorrAr�rCr/rr�<module>r�s���%�
1�
�$�$�$�$�$�$���������������������	�	�	�	�,�'�+�-�-���	�'�	��(�(������	��<�(�(�(��7�2�!�"�"�G��B��4�<�'<�'L�(=�(E�G�G�G�G�
8�8�8�8�8��8�8�8�.(D�(D�(D�V�����u�+����v7�v7�v7�v7�v7���v7�v7�v7�v7�v7rfutures/__pycache__/thread.cpython-311.pyc000064400000025522152402271140014426 0ustar00�

7����'r���z�dZdZddlmZddlZddlZddlZddlZddlZddl	Z	ej
��Zdaej
��Zd�Zeje��ee	d��r"e	jejejej���Gd	�d
e��Zd�ZGd�d
ej��ZGd�dej��ZdS)zImplements ThreadPoolExecutor.z"Brian Quinlan (brian@sweetapp.com)�)�_baseNFc��t5daddd��n#1swxYwYtt�����}|D]\}}|�d���|D]\}}|����dS�NT)�_global_shutdown_lock�	_shutdown�list�_threads_queues�items�put�join)r
�t�qs   �D/opt/alt/python-internal/lib/python3.11/concurrent/futures/thread.py�_python_exitrs���	����	���������������������&�&�(�(�)�)�E������1�	���d����������1�	��������s����register_at_fork)�before�after_in_child�after_in_parentc�:�eZdZd�Zd�Zeej��ZdS)�	_WorkItemc�>�||_||_||_||_dS�N)�future�fn�args�kwargs)�selfrrrrs     r�__init__z_WorkItem.__init__/s"����������	������c��|j���sdS	|j|ji|j��}|j�|��dS#t$r'}|j�|��d}Yd}~dSd}~wwxYwr)r�set_running_or_notify_cancelrrr�
set_result�
BaseException�
set_exception)r�result�excs   r�runz
_WorkItem.run5s����{�7�7�9�9�	��F�	+��T�W�d�i�7�4�;�7�7�F�
�K�"�"�6�*�*�*�*�*���	�	�	��K�%�%�c�*�*�*��D�D�D�D�D�D�D�����	���s�A�
B�A<�<BN)	�__name__�
__module__�__qualname__rr'�classmethod�types�GenericAlias�__class_getitem__�rrrr.sC���������+�+�+�$��E�$6�7�7���rrc�@�|�Y	||�nR#t$rEtj�dd���|��}|�|���YdSwxYw		|�d���}|�<|���~|��}|�|j���~�U|��}ts	|�|j	r |�d|_	|�
d��dS~��#t$r%tj�dd���YdSwxYw)NzException in initializer:T)�exc_info)�blockzException in worker)r#r�LOGGER�critical�_initializer_failed�getr'�_idle_semaphore�releaserr)�executor_reference�
work_queue�initializer�initargs�executor�	work_items      r�_workerr?Es�����	��K��"�"�"���	�	�	��L�!�!�"=��!�M�M�M�)�)�+�+�H��#��,�,�.�.�.��F�F�	����D�	�"���T��2�2�I��$��
�
�����.�-�/�/���'��,�4�4�6�6�6���)�)�+�+�H�
�
�H�,��0B�,��'�)-�H�&����t�$�$�$����7	��8�D�D�D�
����3�d��C�C�C�C�C�C�D���s)�
�AA�A�B
C.�,C.�.+D�Dc��eZdZdZdS)�BrokenThreadPoolzR
    Raised when a worker thread in a ThreadPoolExecutor failed initializing.
    N)r(r)r*�__doc__r/rrrArAps���������rrAc��eZdZej��jZ		dd�Zd�Ze	j
jje_d�Zd�Z
d
d	d
�d�Ze	j
jje_dS)�ThreadPoolExecutorN�r/c��|�&tdtj��pddz��}|dkrtd���|�t	|��std���||_tj��|_	tjd��|_t��|_d|_d|_tj��|_|pd	|���z|_||_||_dS)
a�Initializes a new ThreadPoolExecutor instance.

        Args:
            max_workers: The maximum number of threads that can be used to
                execute the given calls.
            thread_name_prefix: An optional name prefix to give our threads.
            initializer: A callable used to initialize worker threads.
            initargs: A tuple of arguments to pass to the initializer.
        N� ��rz"max_workers must be greater than 0zinitializer must be a callableFzThreadPoolExecutor-%d)�min�os�	cpu_count�
ValueError�callable�	TypeError�_max_workers�queue�SimpleQueue�_work_queue�	threading�	Semaphorer7�set�_threads�_brokenr�Lock�_shutdown_lock�_counter�_thread_name_prefix�_initializer�	_initargs)r�max_workers�thread_name_prefixr;r<s     rrzThreadPoolExecutor.__init__{s������b�2�<�>�>�#6�Q�!�";�<�<�K��!����A�B�B�B��"�8�K�+@�+@�"��<�=�=�=�'��� �,�.�.���(�2�1�5�5�������
�������'�n�.�.���$6�%P�%<�t�}�}���%N�	
� �'���!����rc���|j5t5|jrt|j���|jrtd���trtd���t
j��}t||||��}|j	�
|��|���|cddd��cddd��S#1swxYwYddd��dS#1swxYwYdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdown)rZrrXrAr�RuntimeErrorr�FuturerrSr�_adjust_thread_count)rrrr�f�ws      r�submitzThreadPoolExecutor.submit�s���
�
 �	�	�"7�	�	��|�
5�&�t�|�4�4�4��~�
Q�"�#O�P�P�P��
;�"�$:�;�;�;�����A��!�R��v�.�.�A��� � ��#�#�#��%�%�'�'�'��	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s5�C�BC�,C�C		�	C�C		�
C�C!�$C!c��|j�d���rdS|jfd�}t|j��}||jkr�d|jp||fz}tj|ttj||��|j|j|j
f���}|���|j�|��|jt |<dSdS)Nr)�timeoutc�0�|�d��dSr)r)�_rs  r�
weakref_cbz;ThreadPoolExecutor._adjust_thread_count.<locals>.weakref_cb�s��
�E�E�$�K�K�K�K�Krz%s_%d)�name�targetr)r7�acquirerS�lenrWrPr\rT�Threadr?�weakref�refr]r^�start�addr	)rrl�num_threads�thread_namer
s     rrdz'ThreadPoolExecutor._adjust_thread_count�s�����'�'��'�2�2�	��F�!�,�	�	�	�	��$�-�(�(����*�*�*�!�T�%=�%E��%0�%2�2�K�� �k�'�'.�{�4��'D�'D�'+�'7�'+�'8�'+�~�'7�8�8�8�A�

�G�G�I�I�I��M���a� � � �!%�!1�O�A����+�*rc��|j5d|_		|j���}n#tj$rYn3wxYw|�,|j�t|j�����_	ddd��dS#1swxYwYdS)NzBA thread initializer failed, the thread pool is not usable anymore)	rZrXrS�
get_nowaitrQ�Emptyrr$rA)rr>s  rr5z&ThreadPoolExecutor._initializer_failed�s��
�
 �
	S�
	S�4�D�L�
S�� $� 0� ;� ;� =� =�I�I���{�����E������(��$�2�2�3C�D�L�3Q�3Q�R�R�R�

S��
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S����
	S�
	S�
	S�
	S�
	S�
	Ss,�	A>�,�A>�>�A>�>�2A>�>B�BTF)�cancel_futuresc�h�|j5d|_|rM		|j���}n#tj$rYn wxYw|�|j����L|j�d��ddd��n#1swxYwY|r|j	D]}|�
���dSdSr)rZrrSryrQrzr�cancelrrWr)r�waitr{r>r
s     r�shutdownzThreadPoolExecutor.shutdown�s(��
�
 �	'�	'�!�D�N��	
2�2��$(�$4�$?�$?�$A�$A�	�	�� �;���������� �,�!�(�/�/�1�1�1�
2�
�� � ��&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'� �	��]�
�
���������	�	�
�
s/�B�.�B�A�B�A�9B�B	�B	)NrENr/)T)r(r)r*�	itertools�count�__next__r[rrgr�ExecutorrBrdr5rr/rrrDrDvs��������y�� � �)�H�<>�,.�$"�$"�$"�$"�L���"�^�*�2�F�N�2�2�2�.S�S�S��E������(�~�.�6�H���rrD)rB�
__author__�concurrent.futuresrr�rQrTr,rrrK�WeakKeyDictionaryr	rrYrr�_register_atexit�hasattrrro�_at_fork_reinitr8�objectrr?�BrokenExecutorrAr�rDr/rr�<module>r�s���%�$�
1�
�$�$�$�$�$�$���������������������	�	�	�	�,�'�+�-�-���	�'�	��(�(������	��<�(�(�(��7�2�!�"�"�G��B��4�<�'<�'L�(=�(E�G�G�G�G�
8�8�8�8�8��8�8�8�.(D�(D�(D�V�����u�+����v7�v7�v7�v7�v7���v7�v7�v7�v7�v7rfutures/__pycache__/__init__.cpython-311.pyc000064400000002705152402271140014714 0ustar00�

UN�+�&b��R�dZdZddlmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
dZd�Zd�ZdS)z?Execute computations asynchronously using threads or processes.z"Brian Quinlan (brian@sweetapp.com)�)�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�CancelledError�TimeoutError�InvalidStateError�BrokenExecutor�Future�Executor�wait�as_completed)rrrrrr	r
rrr
�ProcessPoolExecutor�ThreadPoolExecutorc��tdzS)N)�
__author__�__doc__)�__all__���F/opt/alt/python-internal/lib/python3.11/concurrent/futures/__init__.py�__dir__r$s���.�.�.rc�v�|dkr
ddlm}|a|S|dkr
ddlm}|a|St	dt
�d|�����)Nr�)rr)rzmodule z has no attribute )�processr�threadr�AttributeError�__name__)�name�pe�tes   r�__getattr__r!(su���$�$�$�6�6�6�6�6�6� ���	��#�#�#�4�4�4�4�4�4����	�
�I�8�I�I��I�I�
J�
J�JrN)rr�concurrent.futures._baserrrrrrr	r
rrr
rrr!rrr�<module>r#s���F�E�
1�
�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
�� /�/�/�
K�
K�
K�
K�
Krfutures/__pycache__/__init__.cpython-311.opt-2.pyc000064400000002572152402271140015656 0ustar00�

UN�+�&b��P�	dZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZdZ
d�Zd�ZdS)z"Brian Quinlan (brian@sweetapp.com)�)�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�CancelledError�TimeoutError�InvalidStateError�BrokenExecutor�Future�Executor�wait�as_completed)rrrrrr	r
rrr
�ProcessPoolExecutor�ThreadPoolExecutorc��tdzS)N)�
__author__�__doc__)�__all__���F/opt/alt/python-internal/lib/python3.11/concurrent/futures/__init__.py�__dir__r$s���.�.�.rc�v�|dkr
ddlm}|a|S|dkr
ddlm}|a|St	dt
�d|�����)Nr�)rr)rzmodule z has no attribute )�processr�threadr�AttributeError�__name__)�name�pe�tes   r�__getattr__r!(su���$�$�$�6�6�6�6�6�6� ���	��#�#�#�4�4�4�4�4�4����	�
�I�8�I�I��I�I�
J�
J�JrN)r�concurrent.futures._baserrrrrrr	r
rrr
rrr!rrr�<module>r#s���F�
1�
�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
�� /�/�/�
K�
K�
K�
K�
Krfutures/__pycache__/thread.cpython-311.opt-1.pyc000064400000025522152402271140015365 0ustar00�

7����'r���z�dZdZddlmZddlZddlZddlZddlZddlZddl	Z	ej
��Zdaej
��Zd�Zeje��ee	d��r"e	jejejej���Gd	�d
e��Zd�ZGd�d
ej��ZGd�dej��ZdS)zImplements ThreadPoolExecutor.z"Brian Quinlan (brian@sweetapp.com)�)�_baseNFc��t5daddd��n#1swxYwYtt�����}|D]\}}|�d���|D]\}}|����dS�NT)�_global_shutdown_lock�	_shutdown�list�_threads_queues�items�put�join)r
�t�qs   �D/opt/alt/python-internal/lib/python3.11/concurrent/futures/thread.py�_python_exitrs���	����	���������������������&�&�(�(�)�)�E������1�	���d����������1�	��������s����register_at_fork)�before�after_in_child�after_in_parentc�:�eZdZd�Zd�Zeej��ZdS)�	_WorkItemc�>�||_||_||_||_dS�N)�future�fn�args�kwargs)�selfrrrrs     r�__init__z_WorkItem.__init__/s"����������	������c��|j���sdS	|j|ji|j��}|j�|��dS#t$r'}|j�|��d}Yd}~dSd}~wwxYwr)r�set_running_or_notify_cancelrrr�
set_result�
BaseException�
set_exception)r�result�excs   r�runz
_WorkItem.run5s����{�7�7�9�9�	��F�	+��T�W�d�i�7�4�;�7�7�F�
�K�"�"�6�*�*�*�*�*���	�	�	��K�%�%�c�*�*�*��D�D�D�D�D�D�D�����	���s�A�
B�A<�<BN)	�__name__�
__module__�__qualname__rr'�classmethod�types�GenericAlias�__class_getitem__�rrrr.sC���������+�+�+�$��E�$6�7�7���rrc�@�|�Y	||�nR#t$rEtj�dd���|��}|�|���YdSwxYw		|�d���}|�<|���~|��}|�|j���~�U|��}ts	|�|j	r |�d|_	|�
d��dS~��#t$r%tj�dd���YdSwxYw)NzException in initializer:T)�exc_info)�blockzException in worker)r#r�LOGGER�critical�_initializer_failed�getr'�_idle_semaphore�releaserr)�executor_reference�
work_queue�initializer�initargs�executor�	work_items      r�_workerr?Es�����	��K��"�"�"���	�	�	��L�!�!�"=��!�M�M�M�)�)�+�+�H��#��,�,�.�.�.��F�F�	����D�	�"���T��2�2�I��$��
�
�����.�-�/�/���'��,�4�4�6�6�6���)�)�+�+�H�
�
�H�,��0B�,��'�)-�H�&����t�$�$�$����7	��8�D�D�D�
����3�d��C�C�C�C�C�C�D���s)�
�AA�A�B
C.�,C.�.+D�Dc��eZdZdZdS)�BrokenThreadPoolzR
    Raised when a worker thread in a ThreadPoolExecutor failed initializing.
    N)r(r)r*�__doc__r/rrrArAps���������rrAc��eZdZej��jZ		dd�Zd�Ze	j
jje_d�Zd�Z
d
d	d
�d�Ze	j
jje_dS)�ThreadPoolExecutorN�r/c��|�&tdtj��pddz��}|dkrtd���|�t	|��std���||_tj��|_	tjd��|_t��|_d|_d|_tj��|_|pd	|���z|_||_||_dS)
a�Initializes a new ThreadPoolExecutor instance.

        Args:
            max_workers: The maximum number of threads that can be used to
                execute the given calls.
            thread_name_prefix: An optional name prefix to give our threads.
            initializer: A callable used to initialize worker threads.
            initargs: A tuple of arguments to pass to the initializer.
        N� ��rz"max_workers must be greater than 0zinitializer must be a callableFzThreadPoolExecutor-%d)�min�os�	cpu_count�
ValueError�callable�	TypeError�_max_workers�queue�SimpleQueue�_work_queue�	threading�	Semaphorer7�set�_threads�_brokenr�Lock�_shutdown_lock�_counter�_thread_name_prefix�_initializer�	_initargs)r�max_workers�thread_name_prefixr;r<s     rrzThreadPoolExecutor.__init__{s������b�2�<�>�>�#6�Q�!�";�<�<�K��!����A�B�B�B��"�8�K�+@�+@�"��<�=�=�=�'��� �,�.�.���(�2�1�5�5�������
�������'�n�.�.���$6�%P�%<�t�}�}���%N�	
� �'���!����rc���|j5t5|jrt|j���|jrtd���trtd���t
j��}t||||��}|j	�
|��|���|cddd��cddd��S#1swxYwYddd��dS#1swxYwYdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdown)rZrrXrAr�RuntimeErrorr�FuturerrSr�_adjust_thread_count)rrrr�f�ws      r�submitzThreadPoolExecutor.submit�s���
�
 �	�	�"7�	�	��|�
5�&�t�|�4�4�4��~�
Q�"�#O�P�P�P��
;�"�$:�;�;�;�����A��!�R��v�.�.�A��� � ��#�#�#��%�%�'�'�'��	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s5�C�BC�,C�C		�	C�C		�
C�C!�$C!c��|j�d���rdS|jfd�}t|j��}||jkr�d|jp||fz}tj|ttj||��|j|j|j
f���}|���|j�|��|jt |<dSdS)Nr)�timeoutc�0�|�d��dSr)r)�_rs  r�
weakref_cbz;ThreadPoolExecutor._adjust_thread_count.<locals>.weakref_cb�s��
�E�E�$�K�K�K�K�Krz%s_%d)�name�targetr)r7�acquirerS�lenrWrPr\rT�Threadr?�weakref�refr]r^�start�addr	)rrl�num_threads�thread_namer
s     rrdz'ThreadPoolExecutor._adjust_thread_count�s�����'�'��'�2�2�	��F�!�,�	�	�	�	��$�-�(�(����*�*�*�!�T�%=�%E��%0�%2�2�K�� �k�'�'.�{�4��'D�'D�'+�'7�'+�'8�'+�~�'7�8�8�8�A�

�G�G�I�I�I��M���a� � � �!%�!1�O�A����+�*rc��|j5d|_		|j���}n#tj$rYn3wxYw|�,|j�t|j�����_	ddd��dS#1swxYwYdS)NzBA thread initializer failed, the thread pool is not usable anymore)	rZrXrS�
get_nowaitrQ�Emptyrr$rA)rr>s  rr5z&ThreadPoolExecutor._initializer_failed�s��
�
 �
	S�
	S�4�D�L�
S�� $� 0� ;� ;� =� =�I�I���{�����E������(��$�2�2�3C�D�L�3Q�3Q�R�R�R�

S��
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S�
	S����
	S�
	S�
	S�
	S�
	S�
	Ss,�	A>�,�A>�>�A>�>�2A>�>B�BTF)�cancel_futuresc�h�|j5d|_|rM		|j���}n#tj$rYn wxYw|�|j����L|j�d��ddd��n#1swxYwY|r|j	D]}|�
���dSdSr)rZrrSryrQrzr�cancelrrWr)r�waitr{r>r
s     r�shutdownzThreadPoolExecutor.shutdown�s(��
�
 �	'�	'�!�D�N��	
2�2��$(�$4�$?�$?�$A�$A�	�	�� �;���������� �,�!�(�/�/�1�1�1�
2�
�� � ��&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'� �	��]�
�
���������	�	�
�
s/�B�.�B�A�B�A�9B�B	�B	)NrENr/)T)r(r)r*�	itertools�count�__next__r[rrgr�ExecutorrBrdr5rr/rrrDrDvs��������y�� � �)�H�<>�,.�$"�$"�$"�$"�L���"�^�*�2�F�N�2�2�2�.S�S�S��E������(�~�.�6�H���rrD)rB�
__author__�concurrent.futuresrr�rQrTr,rrrK�WeakKeyDictionaryr	rrYrr�_register_atexit�hasattrrro�_at_fork_reinitr8�objectrr?�BrokenExecutorrAr�rDr/rr�<module>r�s���%�$�
1�
�$�$�$�$�$�$���������������������	�	�	�	�,�'�+�-�-���	�'�	��(�(������	��<�(�(�(��7�2�!�"�"�G��B��4�<�'<�'L�(=�(E�G�G�G�G�
8�8�8�8�8��8�8�8�.(D�(D�(D�V�����u�+����v7�v7�v7�v7�v7���v7�v7�v7�v7�v7rfutures/__pycache__/process.cpython-311.pyc000064400000112337152402271140014636 0ustar00�

.��_�B/$��:�dZdZddlZddlmZddlZddlZddlZddl	m
Z
ddlZddlZddl
mZddlZddlZddlmZej��ZdaGd	�d
��Zd�Zeje��dZd
ZGd�de��ZGd�d��Zd�ZGd�de��Z Gd�de��Z!Gd�de��Z"Gd�de
��Z#d�Z$d�Z%		d'd�Z&d(d�Z'Gd�d ej(��Z)da*da+d!�Z,d"�Z-Gd#�d$ej.��Z/Gd%�d&ej0��Z1dS))a-	Implements ProcessPoolExecutor.

The following diagram and text describe the data-flow through the system:

|======================= In-process =====================|== Out-of-process ==|

+----------+     +----------+       +--------+     +-----------+    +---------+
|          |  => | Work Ids |       |        |     | Call Q    |    | Process |
|          |     +----------+       |        |     +-----------+    |  Pool   |
|          |     | ...      |       |        |     | ...       |    +---------+
|          |     | 6        |    => |        |  => | 5, call() | => |         |
|          |     | 7        |       |        |     | ...       |    |         |
| Process  |     | ...      |       | Local  |     +-----------+    | Process |
|  Pool    |     +----------+       | Worker |                      |  #1..n  |
| Executor |                        | Thread |                      |         |
|          |     +----------- +     |        |     +-----------+    |         |
|          | <=> | Work Items | <=> |        | <=  | Result Q  | <= |         |
|          |     +------------+     |        |     +-----------+    |         |
|          |     | 6: call()  |     |        |     | ...       |    |         |
|          |     |    future  |     |        |     | 4, result |    |         |
|          |     | ...        |     |        |     | 3, except |    |         |
+----------+     +------------+     +--------+     +-----------+    +---------+

Executor.submit() called:
- creates a uniquely numbered _WorkItem and adds it to the "Work Items" dict
- adds the id of the _WorkItem to the "Work Ids" queue

Local worker thread:
- reads work ids from the "Work Ids" queue and looks up the corresponding
  WorkItem from the "Work Items" dict: if the work item has been cancelled then
  it is simply removed from the dict, otherwise it is repackaged as a
  _CallItem and put in the "Call Q". New _CallItems are put in the "Call Q"
  until "Call Q" is full. NOTE: the size of the "Call Q" is kept small because
  calls placed in the "Call Q" can no longer be cancelled with Future.cancel().
- reads _ResultItems from "Result Q", updates the future stored in the
  "Work Items" dict and deletes the dict entry

Process #1..n:
- reads _CallItems from "Call Q", executes the calls, and puts the resulting
  _ResultItems in "Result Q"
z"Brian Quinlan (brian@sweetapp.com)�N)�_base)�Queue)�partial)�format_exceptionFc�&�eZdZd�Zd�Zd�Zd�ZdS)�
_ThreadWakeupc�X�d|_tjd���\|_|_dS)NF)�duplex)�_closed�mp�Pipe�_reader�_writer��selfs �E/opt/alt/python-internal/lib/python3.11/concurrent/futures/process.py�__init__z_ThreadWakeup.__init__Cs(�����%'�W�E�%:�%:�%:�"���d�l�l�l�c��|js;d|_|j���|j���dSdS�NT)rr�closerrs rrz_ThreadWakeup.closeGsM���|�	!��D�L��L��� � � ��L��� � � � � �	!�	!rc�L�|js|j�d��dSdS)Nr)rr�
send_bytesrs r�wakeupz_ThreadWakeup.wakeupRs2���|�	)��L�#�#�C�(�(�(�(�(�	)�	)rc��|jsM|j���r6|j���|j����2dSdSdS�N)rr�poll�
recv_bytesrs r�clearz_ThreadWakeup.clearVsl���|�	*��,�#�#�%�%�
*���'�'�)�)�)��,�#�#�%�%�
*�
*�
*�	*�	*�
*�
*rN)�__name__�
__module__�__qualname__rrrr�rrrrBsP������;�;�;�	!�	!�	!�)�)�)�*�*�*�*�*rrc���datt�����}|D]\}}|����|D]\}}|����dSr)�_global_shutdown�list�_threads_wakeups�itemsr�join)r(�_�
thread_wakeup�ts    r�_python_exitr-\sw�����!�'�'�)�)�*�*�E�!�����=�������������1�	��������r��=c��eZdZd�Zd�ZdS)�_RemoteTracebackc��||_dSr��tb)rr4s  rrz_RemoteTraceback.__init__|s
������rc��|jSrr3rs r�__str__z_RemoteTraceback.__str__~s	���w�rN)r r!r"rr6r#rrr1r1{s2�������������rr1c��eZdZd�Zd�ZdS)�_ExceptionWithTracebackc��d�tt|��||����}||_d|j_d|z|_dS)N�z

"""
%s""")r)r�type�exc�
__traceback__r4)rr<r4s   rrz _ExceptionWithTraceback.__init__�sI��
�W�W�%�d�3�i�i��b�9�9�
:�
:�����"&���� �2�%����rc�,�t|j|jffSr)�_rebuild_excr<r4rs r�
__reduce__z"_ExceptionWithTraceback.__reduce__�s���d�h���0�0�0rN)r r!r"rr@r#rrr8r8�s2������&�&�&�1�1�1�1�1rr8c�.�t|��|_|Sr)r1�	__cause__)r<r4s  rr?r?�s��$�R�(�(�C�M��Jrc��eZdZd�ZdS)�	_WorkItemc�>�||_||_||_||_dSr)�future�fn�args�kwargs)rrFrGrHrIs     rrz_WorkItem.__init__�s"����������	�����rN�r r!r"rr#rrrDrD��#����������rrDc��eZdZdd�ZdS)�_ResultItemNc�>�||_||_||_||_dSr)�work_id�	exception�result�exit_pid)rrOrPrQrRs     rrz_ResultItem.__init__�s"�����"������ ��
�
�
r�NNNrJr#rrrMrM�s(������!�!�!�!�!�!rrMc��eZdZd�ZdS)�	_CallItemc�>�||_||_||_||_dSr)rOrGrHrI)rrOrGrHrIs     rrz_CallItem.__init__�s"����������	�����rNrJr#rrrUrU�rKrrUc�.��eZdZdZd�fd�	Z�fd�Z�xZS)�
_SafeQueuez=Safe Queue set exception to the future object linked to a jobrc�x��||_||_||_t���||���dS)N)�ctx)�pending_work_items�
shutdown_lockr+�superr)r�max_sizerZr[r\r+�	__class__s      �rrz_SafeQueue.__init__�s>���"4���*���*���
������s��+�+�+�+�+rc� ��t|t��r�tt|��||j��}td�d�|������|_|j	�
|jd��}|j5|j
���ddd��n#1swxYwY|�|j�|��dSdSt#���||��dS)Nz

"""
{}"""r:)�
isinstancerUrr;r=r1�formatr)rBr[�poprOr\r+rrF�
set_exceptionr]�_on_queue_feeder_error)r�e�objr4�	work_itemr_s     �rrez!_SafeQueue._on_queue_feeder_error�s1����c�9�%�%�	3�!�$�q�'�'�1�a�o�>�>�B�*�>�+@�+@�������+M�+M�N�N�A�K��/�3�3�C�K��F�F�I��#�
,�
,��"�)�)�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,�
�$�� �.�.�q�1�1�1�1�1�%�$�
�G�G�*�*�1�c�2�2�2�2�2s�C�C�C)r)r r!r"�__doc__rre�
__classcell__�r_s@rrXrX�s\�������G�G�,�,�,�,�,�,�
3�
3�
3�
3�
3�
3�
3�
3�
3rrXc'�pK�t|�}	ttj||����}|sdS|V��+)z, Iterates over zip()ed iterables in chunks. TN)�zip�tuple�	itertools�islice)�	chunksize�	iterables�it�chunks    r�_get_chunksru�sI����	�i��B���i�&�r�9�5�5�6�6���	��F�����	rc� ���fd�|D��S)z� Processes a chunk of an iterable passed to map.

    Runs the function passed to map() on a chunk of the
    iterable passed to map.

    This function is run in a separate process.

    c���g|]}�|���Sr#r#)�.0rHrGs  �r�
<listcomp>z"_process_chunk.<locals>.<listcomp>�s���(�(�(�$�B�B��I�(�(�(rr#)rGrts` r�_process_chunkrz�s���)�(�(�(�%�(�(�(�(rc��	|�t||||�����dS#t$rE}t||j��}|�t|||�����Yd}~dSd}~wwxYw)z.Safely send back the given result or exception)rQrPrR�rPrRN)�putrM�
BaseExceptionr8r=)�result_queuerOrQrPrRrfr<s       r�_sendback_resultr��s���9�����W�V�/8�8�M�M�M�	N�	N�	N�	N�	N���9�9�9�%�a���9�9������W��.6�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�����9���s�&*�
A9�:A4�4A9c�:�|�9	||�n2#t$r%tj�dd���YdSwxYwd}d}	|�d���}|�(|�t
j����dS|�|dz
}||krt
j��}	|j|j	i|j
��}t||j||���~nD#t$r7}	t|	|	j��}
t||j|
|�	��Yd}	~	nd}	~	wwxYw~|�dS��)
a�Evaluates calls from call_queue and places the results in result_queue.

    This worker is run in a separate process.

    Args:
        call_queue: A ctx.Queue of _CallItems that will be read and
            evaluated by the worker.
        result_queue: A ctx.Queue of _ResultItems that will written
            to by the worker.
        initializer: A callable initializer, or None
        initargs: A tuple of args for the initializer
    NzException in initializer:T)�exc_infor��blockr.)rQrRr|)r~r�LOGGER�critical�getr}�os�getpidrGrHrIr�rOr8r=)�
call_queuer�initializer�initargs�	max_tasks�	num_tasksrR�	call_item�rrfr<s           r�_process_workerr��s�����	��K��"�"�"���	�	�	��L�!�!�"=��!�M�M�M�
�F�F�		����
�I��H���N�N��N�.�.�	������R�Y�[�[�)�)�)��F�� ���N�I��I�%�%��9�;�;��		��	��i�n�A�	�0@�A�A�A�
�\�9�+<�Q�&.�
0�
0�
0�
0�����	0�	0�	0�)�!�Q�_�=�=�C��\�9�+<��&.�
0�
0�
0�
0�
0�
0�
0�
0�
0�����	0����
����F�9s$�
�+9�9�"C�
D�-D�Dc�^��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Z�xZS)
�_ExecutorManagerThreadatManages the communication between this process and the worker processes.

    The manager is run in a local thread.

    Args:
        executor: A reference to the ProcessPoolExecutor that owns
            this thread. A weakref will be own by the manager as well as
            references to internal objects used to introspect the state of
            the executor.
    c�\��|j|_|j|_|j|jfd�}t	j||��|_|j|_|j	|_
|j|_|j
|_|j|_|j|_t'�����dS)Nc��tj�d��|5|���ddd��dS#1swxYwYdS)Nz?Executor collected: triggering callback for QueueManager wakeup)r�util�debugr)r*r+r\s   r�
weakref_cbz3_ExecutorManagerThread.__init__.<locals>.weakref_cb1s���
�G�M�M�1�
2�
2�
2��
'�
'��$�$�&�&�&�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'�
'�
's�A�A�A)�_executor_manager_thread_wakeupr+�_shutdown_lockr\�weakref�ref�executor_reference�
_processes�	processes�_call_queuer��
_result_queuer�	_work_ids�work_ids_queue�_max_tasks_per_child�max_tasks_per_child�_pending_work_itemsr[r]r)r�executorr�r_s   �rrz_ExecutorManagerThread.__init__#s����
&�E���%�4���&*�%7�%)�%7�	'�	'�	'�	'�#*�+�h�
�"C�"C���"�,���#�.���%�2���'�0���$,�#@�� �#+�">���
���������rc��	|���|���\}}}|r|�|��dS|��|�|��|jdu}|r3|j�|j��}|���~|���x}rP|r4|j	5|�
��ddd��n#1swxYwYn|j���~|�
��rE|���|���|js|���dS��\r)�add_call_item_to_queue�wait_result_broken_or_wakeup�terminate_broken�process_result_itemrRr�rcr)r�r\�_adjust_process_count�_idle_worker_semaphore�release�is_shutting_down�flag_executor_shutting_downr[�join_executor_internals)r�result_item�	is_broken�cause�process_exited�pr�s       r�runz_ExecutorManagerThread.runRs���(	��'�'�)�)�)�,0�,M�,M�,O�,O�)�K��E��
��%�%�e�,�,�,����&��(�(��5�5�5�!,�!5�T�!A��!����*�*�;�+?�@�@�A��F�F�H�H�H� �#�6�6�8�8�8�8�!�%�B�!�/�=�=�$�:�:�<�<�<�=�=�=�=�=�=�=�=�=�=�=����=�=�=�=��!�7�?�?�A�A�A� ��$�$�&�&�
��0�0�2�2�2�
�+�+�-�-�-��.���0�0�2�2�2��F�Q(	s�<C�C!�$C!c�v�	|j���rdS	|j�d���}|j|}|j���r<|j�t||j	|j
|j��d���n|j|=��#tj
$rYdSwxYw��)NTFr�)r��fullr�r�r[rF�set_running_or_notify_cancelr}rUrGrHrI�queue�Empty)rrOrhs   rr�z-_ExecutorManagerThread.add_call_item_to_queues���	���#�#�%�%�
���
��-�1�1��1�>�>��!�3�G�<�	��#�@�@�B�B���O�'�'�	�'�2;�,�2;�.�2;�2B�)D�)D�/3�	(�4�4�4�4��/��8����;�
�
�
����
����	s�B$�$B7�6B7c��|jj}|jjrJ�|jj}||g}d�t	|j�����D��}tj�	||z��}d}d}d}||vrR	|�
��}d}n@#t$r-}	tt|	��|	|	j��}Yd}	~	nd}	~	wwxYw||vrd}|j���|||fS)Nc��g|]	}|j��
Sr#)�sentinel�rxr�s  rryzG_ExecutorManagerThread.wait_result_broken_or_wakeup.<locals>.<listcomp>�s��N�N�N�1�A�J�N�N�NrTF)rrr+rr&r��valuesr�
connection�wait�recvr~rr;r=r)
r�
result_reader�
wakeup_reader�readers�worker_sentinels�readyr�r�r�rfs
          rr�z3_ExecutorManagerThread.wait_result_broken_or_wakeup�s/���)�1�
��%�-�-�-�-��*�2�
� �-�0��N�N��T�^�5J�5J�5L�5L�0M�0M�N�N�N���
�"�"�7�-=�#=�>�>�����	����E�!�!�
F�+�0�0�2�2��!�	�	�� �
F�
F�
F�(��a���!�Q�_�E�E�����������
F�����e�
#�
#��I�	
�� � �"�"�"��I�u�,�,s�B�
C�)#C�Cc���t|t��rc|���sJ�|j�|��}|���|js|���dSdS|j�|jd��}|�I|j	r!|j
�|j	��dS|j
�|j
��dSdSr)ra�intr�r�rcr)r�r[rOrPrFrd�
set_resultrQ)rr�r�rhs    rr�z*_ExecutorManagerThread.process_result_item�s����k�3�'�'�	D��(�(�*�*�*�*�*���"�"�;�/�/�A�
�F�F�H�H�H��>�
��,�,�.�.�.���
�
�
�/�3�3�K�4G��N�N�I��$��(�D��$�2�2�;�3H�I�I�I�I�I��$�/�/��0B�C�C�C�C�C�	%�$rc�N�|���}tp
|dup|jSr)r�r%�_shutdown_thread)rr�s  rr�z'_ExecutorManagerThread.is_shutting_down�s4���*�*�,�,��
!�-�H��$4�-��,�	.rc��|���}|�d|_d|_d}td��}|�+t	dd�|���d���|_|j���D] \}}|j	�
|��~�!|j���|j�
��D]}|����|jj���t$jdkr|jj���|���dS)NzKA child process terminated abruptly, the process pool is not usable anymoreTz^A process in the process pool was terminated abruptly while the future was running or pending.z
'''
r:z'''�win32)r��_brokenr��BrokenProcessPoolr1r)rBr[r(rFrdrr�r��	terminater�rr�sys�platformrr�)rr�r��bperOrhr�s       rr�z'_ExecutorManagerThread.terminate_broken�sX���*�*�,�,����!1�H��)-�H�%��H� �!6�7�7����,�-�"�'�'�%�.�.�-�-�-�/�/�C�M�#'�"9�"?�"?�"A�"A�	�	��G�Y���*�*�3�/�/�/��	���%�%�'�'�'���&�&�(�(�	�	�A�
�K�K�M�M�M�M�	
���%�%�'�'�'��<�7�"�"��O�#�)�)�+�+�+�	
�$�$�&�&�&�&�&rc�T�|���}|��d|_|jr�i}|j���D]#\}}|j���s|||<�$||_		|j���n#tj
$rYnwxYw�1d|_dSdSdS)NTF)r�r��_cancel_pending_futuresr[r(rF�cancelr��
get_nowaitr�r�)rr��new_pending_work_itemsrOrhs     rr�z2_ExecutorManagerThread.flag_executor_shutting_down	s����*�*�,�,����(,�H�%��/�
9�*,�&�*.�*A�*G�*G�*I�*I�D�D�&�G�Y�$�+�2�2�4�4�D�:C�.�w�7��*@��'����+�6�6�8�8�8�8�� �;�����������49��0�0�0�) ��
9�
9s�-B�B�Bc�L�|���}d}||kr�|���dkrmt||z
��D]8}	|j�d��|dz
}�##tj$rYnwxYw||kr|���dk�idSdSdSdS)Nrr.)�get_n_children_alive�ranger��
put_nowaitr��Full)r�n_children_to_stop�n_sentinels_sent�is    r�shutdown_workersz'_ExecutorManagerThread.shutdown_workers#s���!�6�6�8�8���� �"4�4�4��-�-�/�/�!�3�3��-�0@�@�A�A�
�
����O�.�.�t�4�4�4�$��)�$�$���z�����E�E�����
 �"4�4�4��-�-�/�/�!�3�3�3�3�5�4�3�3�5�4s�
A*�*A=�<A=c�b�|���|j���|j���|j5|j���ddd��n#1swxYwY|j���D]}|����dSr)	r�r�r�join_threadr\r+r�r�r)�rr�s  rr�z._ExecutorManagerThread.join_executor_internals1s������������������#�#�%�%�%�
�
�	'�	'���$�$�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'���&�&�(�(�	�	�A�
�F�F�H�H�H�H�	�	s�A4�4A8�;A8c�b�td�|j���D����S)Nc3�>K�|]}|���V��dSr)�is_aliver�s  r�	<genexpr>z>_ExecutorManagerThread.get_n_children_alive.<locals>.<genexpr>?s*����A�A�A�1�:�:�<�<�A�A�A�A�A�Ar)�sumr�r�rs rr�z+_ExecutorManagerThread.get_n_children_alive=s-���A�A���)>�)>�)@�)@�A�A�A�A�A�Ar)r r!r"rirr�r�r�r�r�r�r�r�r�r�rjrks@rr�r�s��������	�	�-�-�-�-�-�^+�+�+�Z���.!-�!-�!-�FD�D�D�..�.�.�-'�-'�-'�^9�9�9�4���
�
�
�B�B�B�B�B�B�Brr�c�L�trtrtt���da	ddl}n$#t$rdatt���wxYw	tjd��}n#ttf$rYdSwxYw|dkrdS|dkrdSd|zatt���)NTrzxThis Python build lacks multiprocessing.synchronize, usually due to named semaphores being unavailable on this platform.�SC_SEM_NSEMS_MAX����z@system provides too few semaphores (%d available, 256 necessary))	�_system_limits_checked�_system_limited�NotImplementedError�multiprocessing.synchronize�ImportErrorr��sysconf�AttributeError�
ValueError)�multiprocessing�	nsems_maxs  r�_check_system_limitsr�Fs����7��	7�%�o�6�6�6�!��3�*�*�*�*�*���3�3�3�
F�	�"�/�2�2�2�3������J�1�2�2�	�	���J�'������������B���	���C���	��4�6?�@�O�
�o�
.�
.�.s�+�!A�A%�%A:�9A:c#�pK�|D]0}|���|r|���V�|��1dS)z�
    Specialized implementation of itertools.chain.from_iterable.
    Each item in *iterable* should be a list.  This function is
    careful not to keep references to yielded objects.
    N)�reverserc)�iterable�elements  r�_chain_from_iterable_of_listsrfsX����� � ���������	 ��+�+�-�-�����	 �� � rc��eZdZdZdS)r�zy
    Raised when a process in a ProcessPoolExecutor terminated abruptly
    while a future was in the running state.
    N)r r!r"rir#rrr�r�rs���������rr�c���eZdZ		ddd�d�Zd�Zd�Zd�Zd�Zd	�Ze	j
jje_dd
d��fd�
Zddd�d�Z
e	j
j
je
_�xZS)�ProcessPoolExecutorNr#)r�c��t��|�Jtj��pd|_tjdkrt
t|j��|_nN|dkrtd���tjdkr"|tkrtdt�����||_|�*|�tj
d��}ntj
��}||_|j�d�	��d
k|_
|�t|��std���||_||_|�gt%|t&��std���|dkrtd
���|j�d�	��d
krtd���||_d|_i|_d|_t1j��|_t1jd��|_d|_d|_i|_d|_ tC��|_"|jtFz}tI||j|j|j|j"���|_%d|j%_&|�'��|_(tSj*��|_+dS)aHInitializes a new ProcessPoolExecutor instance.

        Args:
            max_workers: The maximum number of processes that can be used to
                execute the given calls. If None or not given then as many
                worker processes will be created as the machine has processors.
            mp_context: A multiprocessing context to launch the workers. This
                object should provide SimpleQueue, Queue and Process. Useful
                to allow specific multiprocessing start methods.
            initializer: A callable used to initialize worker processes.
            initargs: A tuple of arguments to pass to the initializer.
            max_tasks_per_child: The maximum number of tasks a worker process
                can complete before it will exit and be replaced with a fresh
                worker process. The default of None means worker process will
                live as long as the executor. Requires a non-'fork' mp_context
                start method. When given, we default to using 'spawn' if no
                mp_context is supplied.
        Nr.r�rz"max_workers must be greater than 0zmax_workers must be <= �spawnF)�
allow_none�forkzinitializer must be a callablez&max_tasks_per_child must be an integerz max_tasks_per_child must be >= 1zpmax_tasks_per_child is incompatible with the 'fork' multiprocessing start method; supply a different mp_context.)r^rZr[r\r+T),r�r��	cpu_count�_max_workersr�r��min�_MAX_WINDOWS_WORKERSr�r�get_context�_mp_context�get_start_method�#_safe_to_dynamically_spawn_children�callable�	TypeError�_initializer�	_initargsrar�r��_executor_manager_threadr�r��	threading�Lockr��	Semaphorer�r��_queue_countr�r�rr��EXTRA_QUEUED_CALLSrXr��
_ignore_epipe�SimpleQueuer�r�rr�)r�max_workers�
mp_contextr�r�r��
queue_sizes       rrzProcessPoolExecutor.__init__zs���(	������ "���� 3�!�D���|�w�&�&�$'�(<�(,�(9�%;�%;��!���a��� �!E�F�F�F��,�'�)�)��2�2�2� �D�.B�D�D�F�F�F�!,�D����"�.��^�G�4�4�
�
��^�-�-�
�%���� �1�1�U�1�C�C�v�M�	
�0��"�8�K�+@�+@�"��<�=�=�=�'���!����*��1�3�7�7�
E�� H�I�I�I�$��)�)� �!C�D�D�D���0�0�E�0�B�B�f�L�L� �"C�D�D�D�%8��!�)-��%����!&���'�n�.�.���&/�&9�!�&<�&<��#�������#%�� �',��$�0=����,��&�);�;�
�%��T�%5�#�7��-��>�	@�@�@���*.���&�'�3�3�5�5����������rc���|j�^|js|���t|��|_|j���|jt|j<dSdSr)rr�_launch_processesr��startr�r'rs r�_start_executor_manager_threadz2ProcessPoolExecutor._start_executor_manager_thread�sn���(�0��;�
)��&�&�(�(�(�,B�4�,H�,H�D�)��)�/�/�1�1�1��4�
�T�:�;�;�;�
1�0rc��|j�d���rdSt|j��}||jkr|���dSdS)NF)�blocking)r��acquire�lenr�r
�_spawn_process)r�
process_counts  rr�z)ProcessPoolExecutor._adjust_process_count�sb���&�.�.��.�>�>�	��F��D�O�,�,�
��4�,�,�,�
���!�!�!�!�!�-�,rc��|jr
Jd���tt|j��|j��D]}|����dS)NzhProcesses cannot be fork()ed after the thread has started, deadlock in the child processes could result.)rr�r'r�r
r()rr*s  rr!z%ProcessPoolExecutor._launch_processessp���0�	A�	A�@�	A�	A�0��s�4�?�+�+�T�->�?�?�	"�	"�A����!�!�!�!�	"�	"rc���|j�t|j|j|j|j|jf���}|���||j	|j
<dS)N)�targetrH)r�Processr�r�r�rrr�r"r��pidr�s  rr(z"ProcessPoolExecutor._spawn_process	sg����$�$�"��"��$��#��.��+�	-�
%�
.�
.��	
���	�	�	�!"�������rc�,�|j5|jrt|j���|jrt	d���t
rt	d���t
j��}t||||��}||j	|j
<|j�|j
��|xj
dz
c_
|j
���|jr|���|���|cddd��S#1swxYwYdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdownr.)r�r�r�r��RuntimeErrorr%r�FuturerDr�rr�r}r�rrr�r#)rrGrHrI�f�ws      r�submitzProcessPoolExecutor.submitsg��
�
 �	�	��|�
6�'���5�5�5��$�
Q�"�#O�P�P�P��
;�"�$:�;�;�;�����A��!�R��v�.�.�A�:;�D�$�T�%6�7��N���t�0�1�1�1�����"����0�7�7�9�9�9��7�
-��*�*�,�,�,��/�/�1�1�1��+	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�C4D	�	D
�D
r.)�timeoutrqc����|dkrtd���t���tt|��t|d|i�|���}t
|��S)ajReturns an iterator equivalent to map(fn, iter).

        Args:
            fn: A callable that will take as many arguments as there are
                passed iterables.
            timeout: The maximum number of seconds to wait. If None, then there
                is no limit on the wait time.
            chunksize: If greater than one, the iterables will be chopped into
                chunks of size chunksize and submitted to the process pool.
                If set to one, the items in the list will be sent one at a time.

        Returns:
            An iterator equivalent to: map(func, *iterables) but the calls may
            be evaluated out-of-order.

        Raises:
            TimeoutError: If the entire result iterator could not be generated
                before the given timeout.
            Exception: If fn(*args) raises for any values.
        r.zchunksize must be >= 1.rq)r5)r�r]�maprrzrur)rrGr5rqrr�resultsr_s      �rr7zProcessPoolExecutor.map-sh���*�q�=�=��6�7�7�7��'�'�+�+�g�n�b�9�9�)�9�J�	�J�J�&-��/�/��-�W�5�5�5rTF)�cancel_futuresc�n�|j5||_d|_|j�|j���ddd��n#1swxYwY|j�|r|j���d|_d|_|j�|r|j�	��d|_d|_
d|_dSr)r�r�r�r�rrr)r�r�rr�)rr�r9s   r�shutdownzProcessPoolExecutor.shutdownJs��
�
 �	>�	>�+9�D�(�$(�D�!��3�?��4�;�;�=�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>��(�4��4��)�.�.�0�0�0�)-��%������)�d�)���$�$�&�&�&�!������/3��,�,�,s�/A�A�
A)NNNr#)T)r r!r"rr#r�r!r(r4r�Executorrir7r;rjrks@rrrys��������48�,.�l'�GK�l'�l'�l'�l'�l'�\5�5�5�
"�
"�
"�"�"�"�	#�	#�	#����.�^�*�2�F�N�*.�!�6�6�6�6�6�6�6�:4�E�4�4�4�4�4�(�~�.�6�H�����rrrSr)2ri�
__author__r��concurrent.futuresrr�r�r�multiprocessing.connection�multiprocessing.queuesrrr��	functoolsrror��	tracebackr�WeakKeyDictionaryr'r%rr-�_register_atexitrr�	Exceptionr1r8r?�objectrDrMrUrXrurzr�r��Threadr�r�r�r�r�BrokenExecutorr�r<rr#rr�<module>rIsY��(�(�T2�
�	�	�	�	�$�$�$�$�$�$���������!�!�!�!�(�(�(�(�(�(�������������������
�
�
�
�&�&�&�&�&�&�-�7�,�.�.����*�*�*�*�*�*�*�*�4����	��<�(�(�(����������y����	1�	1�	1�	1�	1�	1�	1�	1�������������!�!�!�!�!�&�!�!�!����������3�3�3�3�3��3�3�3�2���	)�	)�	)�DH�"�	9�	9�	9�	9�3�3�3�3�lhB�hB�hB�hB�hB�Y�-�hB�hB�hB�V	����/�/�/�@	 �	 �	 �������,����e7�e7�e7�e7�e7�%�.�e7�e7�e7�e7�e7rfutures/__pycache__/process.cpython-311.opt-2.pyc000064400000076355152402271140015607 0ustar00�

.��_�B/$��8�	dZddlZddlmZddlZddlZddlZddlm	Z	ddl
Z
ddlZddlm
Z
ddlZddlZddlmZej��ZdaGd�d	��Zd
�Ze
je��dZdZGd
�de��ZGd�d��Zd�ZGd�de��ZGd�de��Z Gd�de��Z!Gd�de	��Z"d�Z#d�Z$		d&d�Z%d'd�Z&Gd�de
j'��Z(da)da*d �Z+d!�Z,Gd"�d#ej-��Z.Gd$�d%ej/��Z0dS)(z"Brian Quinlan (brian@sweetapp.com)�N)�_base)�Queue)�partial)�format_exceptionFc�&�eZdZd�Zd�Zd�Zd�ZdS)�
_ThreadWakeupc�X�d|_tjd���\|_|_dS)NF)�duplex)�_closed�mp�Pipe�_reader�_writer��selfs �E/opt/alt/python-internal/lib/python3.11/concurrent/futures/process.py�__init__z_ThreadWakeup.__init__Cs(�����%'�W�E�%:�%:�%:�"���d�l�l�l�c��|js;d|_|j���|j���dSdS�NT)rr�closerrs rrz_ThreadWakeup.closeGsM���|�	!��D�L��L��� � � ��L��� � � � � �	!�	!rc�L�|js|j�d��dSdS)Nr)rr�
send_bytesrs r�wakeupz_ThreadWakeup.wakeupRs2���|�	)��L�#�#�C�(�(�(�(�(�	)�	)rc��|jsM|j���r6|j���|j����2dSdSdS�N)rr�poll�
recv_bytesrs r�clearz_ThreadWakeup.clearVsl���|�	*��,�#�#�%�%�
*���'�'�)�)�)��,�#�#�%�%�
*�
*�
*�	*�	*�
*�
*rN)�__name__�
__module__�__qualname__rrrr�rrrrBsP������;�;�;�	!�	!�	!�)�)�)�*�*�*�*�*rrc���datt�����}|D]\}}|����|D]\}}|����dSr)�_global_shutdown�list�_threads_wakeups�itemsr�join)r(�_�
thread_wakeup�ts    r�_python_exitr-\sw�����!�'�'�)�)�*�*�E�!�����=�������������1�	��������r��=c��eZdZd�Zd�ZdS)�_RemoteTracebackc��||_dSr��tb)rr4s  rrz_RemoteTraceback.__init__|s
������rc��|jSrr3rs r�__str__z_RemoteTraceback.__str__~s	���w�rN)r r!r"rr6r#rrr1r1{s2�������������rr1c��eZdZd�Zd�ZdS)�_ExceptionWithTracebackc��d�tt|��||����}||_d|j_d|z|_dS)N�z

"""
%s""")r)r�type�exc�
__traceback__r4)rr<r4s   rrz _ExceptionWithTraceback.__init__�sI��
�W�W�%�d�3�i�i��b�9�9�
:�
:�����"&���� �2�%����rc�,�t|j|jffSr)�_rebuild_excr<r4rs r�
__reduce__z"_ExceptionWithTraceback.__reduce__�s���d�h���0�0�0rN)r r!r"rr@r#rrr8r8�s2������&�&�&�1�1�1�1�1rr8c�.�t|��|_|Sr)r1�	__cause__)r<r4s  rr?r?�s��$�R�(�(�C�M��Jrc��eZdZd�ZdS)�	_WorkItemc�>�||_||_||_||_dSr)�future�fn�args�kwargs)rrFrGrHrIs     rrz_WorkItem.__init__�s"����������	�����rN�r r!r"rr#rrrDrD��#����������rrDc��eZdZdd�ZdS)�_ResultItemNc�>�||_||_||_||_dSr)�work_id�	exception�result�exit_pid)rrOrPrQrRs     rrz_ResultItem.__init__�s"�����"������ ��
�
�
r�NNNrJr#rrrMrM�s(������!�!�!�!�!�!rrMc��eZdZd�ZdS)�	_CallItemc�>�||_||_||_||_dSr)rOrGrHrI)rrOrGrHrIs     rrz_CallItem.__init__�s"����������	�����rNrJr#rrrUrU�rKrrUc�,��eZdZ	d�fd�	Z�fd�Z�xZS)�
_SafeQueuerc�x��||_||_||_t���||���dS)N)�ctx)�pending_work_items�
shutdown_lockr+�superr)r�max_sizerZr[r\r+�	__class__s      �rrz_SafeQueue.__init__�s>���"4���*���*���
������s��+�+�+�+�+rc� ��t|t��r�tt|��||j��}td�d�|������|_|j	�
|jd��}|j5|j
���ddd��n#1swxYwY|�|j�|��dSdSt#���||��dS)Nz

"""
{}"""r:)�
isinstancerUrr;r=r1�formatr)rBr[�poprOr\r+rrF�
set_exceptionr]�_on_queue_feeder_error)r�e�objr4�	work_itemr_s     �rrez!_SafeQueue._on_queue_feeder_error�s1����c�9�%�%�	3�!�$�q�'�'�1�a�o�>�>�B�*�>�+@�+@�������+M�+M�N�N�A�K��/�3�3�C�K��F�F�I��#�
,�
,��"�)�)�+�+�+�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,�
,����
,�
,�
,�
,�
�$�� �.�.�q�1�1�1�1�1�%�$�
�G�G�*�*�1�c�2�2�2�2�2s�C�C�C)r)r r!r"rre�
__classcell__�r_s@rrXrX�sY�������G�,�,�,�,�,�,�
3�
3�
3�
3�
3�
3�
3�
3�
3rrXc'�rK�	t|�}	ttj||����}|sdS|V��+r)�zip�tuple�	itertools�islice)�	chunksize�	iterables�it�chunks    r�_get_chunksrt�sL����6�	�i��B���i�&�r�9�5�5�6�6���	��F�����	rc�"��	�fd�|D��S)Nc���g|]}�|���Sr#r#)�.0rHrGs  �r�
<listcomp>z"_process_chunk.<locals>.<listcomp>�s���(�(�(�$�B�B��I�(�(�(rr#)rGrss` r�_process_chunkry�s$����)�(�(�(�%�(�(�(�(rc��		|�t||||�����dS#t$rE}t||j��}|�t|||�����Yd}~dSd}~wwxYw)N)rQrPrR�rPrR)�putrM�
BaseExceptionr8r=)�result_queuerOrQrPrRrfr<s       r�_sendback_resultr�s���8�9�����W�V�/8�8�M�M�M�	N�	N�	N�	N�	N���9�9�9�%�a���9�9������W��.6�8�8�8�	9�	9�	9�	9�	9�	9�	9�	9�	9�����9���s�&+�
A:�:A5�5A:c�<�	|�9	||�n2#t$r%tj�dd���YdSwxYwd}d}	|�d���}|�(|�t
j����dS|�|dz
}||krt
j��}	|j|j	i|j
��}t||j||���~nD#t$r7}	t|	|	j��}
t||j|
|���Yd}	~	nd}	~	wwxYw~|�dS��)	NzException in initializer:T)�exc_infor��blockr.)rQrRr{)r}r�LOGGER�critical�getr|�os�getpidrGrHrIrrOr8r=)�
call_queuer~�initializer�initargs�	max_tasks�	num_tasksrR�	call_item�rrfr<s           r�_process_workerr��s������	��K��"�"�"���	�	�	��L�!�!�"=��!�M�M�M�
�F�F�		����
�I��H���N�N��N�.�.�	������R�Y�[�[�)�)�)��F�� ���N�I��I�%�%��9�;�;��		��	��i�n�A�	�0@�A�A�A�
�\�9�+<�Q�&.�
0�
0�
0�
0�����	0�	0�	0�)�!�Q�_�=�=�C��\�9�+<��&.�
0�
0�
0�
0�
0�
0�
0�
0�
0�����	0����
����F�9s$��+:�:�#C�
D�-D�Dc�\��eZdZ	�fd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
�xZS)�_ExecutorManagerThreadc�\��|j|_|j|_|j|jfd�}t	j||��|_|j|_|j	|_
|j|_|j
|_|j|_|j|_t'�����dS)Nc��tj�d��|5|���ddd��dS#1swxYwYdS)Nz?Executor collected: triggering callback for QueueManager wakeup)r�util�debugr)r*r+r\s   r�
weakref_cbz3_ExecutorManagerThread.__init__.<locals>.weakref_cb1s���
�G�M�M�1�
2�
2�
2��
'�
'��$�$�&�&�&�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'�
'����
'�
'�
'�
'�
'�
's�A�A�A)�_executor_manager_thread_wakeupr+�_shutdown_lockr\�weakref�ref�executor_reference�
_processes�	processes�_call_queuer��
_result_queuer~�	_work_ids�work_ids_queue�_max_tasks_per_child�max_tasks_per_child�_pending_work_itemsr[r]r)r�executorr�r_s   �rrz_ExecutorManagerThread.__init__#s����
&�E���%�4���&*�%7�%)�%7�	'�	'�	'�	'�#*�+�h�
�"C�"C���"�,���#�.���%�2���'�0���$,�#@�� �#+�">���
���������rc��	|���|���\}}}|r|�|��dS|��|�|��|jdu}|r3|j�|j��}|���~|���x}rP|r4|j	5|�
��ddd��n#1swxYwYn|j���~|�
��rE|���|���|js|���dS��\r)�add_call_item_to_queue�wait_result_broken_or_wakeup�terminate_broken�process_result_itemrRr�rcr)r�r\�_adjust_process_count�_idle_worker_semaphore�release�is_shutting_down�flag_executor_shutting_downr[�join_executor_internals)r�result_item�	is_broken�cause�process_exited�pr�s       r�runz_ExecutorManagerThread.runRs���(	��'�'�)�)�)�,0�,M�,M�,O�,O�)�K��E��
��%�%�e�,�,�,����&��(�(��5�5�5�!,�!5�T�!A��!����*�*�;�+?�@�@�A��F�F�H�H�H� �#�6�6�8�8�8�8�!�%�B�!�/�=�=�$�:�:�<�<�<�=�=�=�=�=�=�=�=�=�=�=����=�=�=�=��!�7�?�?�A�A�A� ��$�$�&�&�
��0�0�2�2�2�
�+�+�-�-�-��.���0�0�2�2�2��F�Q(	s�<C�C!�$C!c�v�	|j���rdS	|j�d���}|j|}|j���r<|j�t||j	|j
|j��d���n|j|=��#tj
$rYdSwxYw��)NTFr�)r��fullr�r�r[rF�set_running_or_notify_cancelr|rUrGrHrI�queue�Empty)rrOrhs   rr�z-_ExecutorManagerThread.add_call_item_to_queues���	���#�#�%�%�
���
��-�1�1��1�>�>��!�3�G�<�	��#�@�@�B�B���O�'�'�	�'�2;�,�2;�.�2;�2B�)D�)D�/3�	(�4�4�4�4��/��8����;�
�
�
����
����	s�B$�$B7�6B7c���|jj}|jj}||g}d�t|j�����D��}tj�||z��}d}d}d}||vrR	|�	��}d}n@#t$r-}	tt|	��|	|	j
��}Yd}	~	nd}	~	wwxYw||vrd}|j���|||fS)Nc��g|]	}|j��
Sr#)�sentinel�rwr�s  rrxzG_ExecutorManagerThread.wait_result_broken_or_wakeup.<locals>.<listcomp>�s��N�N�N�1�A�J�N�N�NrTF)r~rr+r&r��valuesr�
connection�wait�recvr}rr;r=r)
r�
result_reader�
wakeup_reader�readers�worker_sentinels�readyr�r�r�rfs
          rr�z3_ExecutorManagerThread.wait_result_broken_or_wakeup�s���)�1�
��*�2�
� �-�0��N�N��T�^�5J�5J�5L�5L�0M�0M�N�N�N���
�"�"�7�-=�#=�>�>�����	����E�!�!�
F�+�0�0�2�2��!�	�	�� �
F�
F�
F�(��a���!�Q�_�E�E�����������
F�����e�
#�
#��I�	
�� � �"�"�"��I�u�,�,s�:B�
C�#C�Cc��t|t��rM|j�|��}|���|js|���dSdS|j�|jd��}|�I|jr!|j	�
|j��dS|j	�|j��dSdSr)
ra�intr�rcr)r�r[rOrPrFrd�
set_resultrQ)rr�r�rhs    rr�z*_ExecutorManagerThread.process_result_item�s����k�3�'�'�	D���"�"�;�/�/�A�
�F�F�H�H�H��>�
��,�,�.�.�.���
�
�
�/�3�3�K�4G��N�N�I��$��(�D��$�2�2�;�3H�I�I�I�I�I��$�/�/��0B�C�C�C�C�C�	%�$rc�N�|���}tp
|dup|jSr)r�r%�_shutdown_thread)rr�s  rr�z'_ExecutorManagerThread.is_shutting_down�s4���*�*�,�,��
!�-�H��$4�-��,�	.rc��|���}|�d|_d|_d}td��}|�+t	dd�|���d���|_|j���D] \}}|j	�
|��~�!|j���|j�
��D]}|����|jj���t$jdkr|jj���|���dS)NzKA child process terminated abruptly, the process pool is not usable anymoreTz^A process in the process pool was terminated abruptly while the future was running or pending.z
'''
r:z'''�win32)r��_brokenr��BrokenProcessPoolr1r)rBr[r(rFrdrr�r��	terminater�rr�sys�platformrr�)rr�r��bperOrhr�s       rr�z'_ExecutorManagerThread.terminate_broken�sX���*�*�,�,����!1�H��)-�H�%��H� �!6�7�7����,�-�"�'�'�%�.�.�-�-�-�/�/�C�M�#'�"9�"?�"?�"A�"A�	�	��G�Y���*�*�3�/�/�/��	���%�%�'�'�'���&�&�(�(�	�	�A�
�K�K�M�M�M�M�	
���%�%�'�'�'��<�7�"�"��O�#�)�)�+�+�+�	
�$�$�&�&�&�&�&rc�T�|���}|��d|_|jr�i}|j���D]#\}}|j���s|||<�$||_		|j���n#tj
$rYnwxYw�1d|_dSdSdS)NTF)r�r��_cancel_pending_futuresr[r(rF�cancelr��
get_nowaitr�r�)rr��new_pending_work_itemsrOrhs     rr�z2_ExecutorManagerThread.flag_executor_shutting_down	s����*�*�,�,����(,�H�%��/�
9�*,�&�*.�*A�*G�*G�*I�*I�D�D�&�G�Y�$�+�2�2�4�4�D�:C�.�w�7��*@��'����+�6�6�8�8�8�8�� �;�����������49��0�0�0�) ��
9�
9s�-B�B�Bc�L�|���}d}||kr�|���dkrmt||z
��D]8}	|j�d��|dz
}�##tj$rYnwxYw||kr|���dk�idSdSdSdS)Nrr.)�get_n_children_alive�ranger��
put_nowaitr��Full)r�n_children_to_stop�n_sentinels_sent�is    r�shutdown_workersz'_ExecutorManagerThread.shutdown_workers#s���!�6�6�8�8���� �"4�4�4��-�-�/�/�!�3�3��-�0@�@�A�A�
�
����O�.�.�t�4�4�4�$��)�$�$���z�����E�E�����
 �"4�4�4��-�-�/�/�!�3�3�3�3�5�4�3�3�5�4s�
A*�*A=�<A=c�b�|���|j���|j���|j5|j���ddd��n#1swxYwY|j���D]}|����dSr)	r�r�r�join_threadr\r+r�r�r)�rr�s  rr�z._ExecutorManagerThread.join_executor_internals1s������������������#�#�%�%�%�
�
�	'�	'���$�$�&�&�&�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'�	'����	'�	'�	'�	'���&�&�(�(�	�	�A�
�F�F�H�H�H�H�	�	s�A4�4A8�;A8c�b�td�|j���D����S)Nc3�>K�|]}|���V��dSr)�is_aliver�s  r�	<genexpr>z>_ExecutorManagerThread.get_n_children_alive.<locals>.<genexpr>?s*����A�A�A�1�:�:�<�<�A�A�A�A�A�Ar)�sumr�r�rs rr�z+_ExecutorManagerThread.get_n_children_alive=s-���A�A���)>�)>�)@�)@�A�A�A�A�A�Ar)r r!r"rr�r�r�r�r�r�r�r�r�r�rirjs@rr�r�s��������	�-�-�-�-�-�^+�+�+�Z���.!-�!-�!-�FD�D�D�..�.�.�-'�-'�-'�^9�9�9�4���
�
�
�B�B�B�B�B�B�Brr�c�L�trtrtt���da	ddl}n$#t$rdatt���wxYw	tjd��}n#ttf$rYdSwxYw|dkrdS|dkrdSd|zatt���)NTrzxThis Python build lacks multiprocessing.synchronize, usually due to named semaphores being unavailable on this platform.�SC_SEM_NSEMS_MAX����z@system provides too few semaphores (%d available, 256 necessary))	�_system_limits_checked�_system_limited�NotImplementedError�multiprocessing.synchronize�ImportErrorr��sysconf�AttributeError�
ValueError)�multiprocessing�	nsems_maxs  r�_check_system_limitsr�Fs����7��	7�%�o�6�6�6�!��3�*�*�*�*�*���3�3�3�
F�	�"�/�2�2�2�3������J�1�2�2�	�	���J�'������������B���	���C���	��4�6?�@�O�
�o�
.�
.�.s�+�!A�A%�%A:�9A:c#�rK�	|D]0}|���|r|���V�|��1dSr)�reverserc)�iterable�elements  r�_chain_from_iterable_of_listsrfs]�����
� � ���������	 ��+�+�-�-�����	 �� � rc��eZdZdS)r�N)r r!r"r#rrr�r�rs�������rr�c���eZdZ		ddd�d�Zd�Zd�Zd�Zd�Zd	�Ze	j
jje_dd
d��fd�
Zddd�d�Z
e	j
j
je
_�xZS)�ProcessPoolExecutorNr#)r�c��	t��|�Jtj��pd|_tjdkrt
t|j��|_nN|dkrtd���tjdkr"|tkrtdt�����||_|�*|�tj
d��}ntj
��}||_|j�d���d	k|_
|�t|��std
���||_||_|�gt%|t&��std���|dkrtd���|j�d���d	krtd
���||_d|_i|_d|_t1j��|_t1jd��|_d|_d|_i|_d|_ tC��|_"|jtFz}tI||j|j|j|j"���|_%d|j%_&|�'��|_(tSj*��|_+dS)Nr.r�rz"max_workers must be greater than 0zmax_workers must be <= �spawnF)�
allow_none�forkzinitializer must be a callablez&max_tasks_per_child must be an integerz max_tasks_per_child must be >= 1zpmax_tasks_per_child is incompatible with the 'fork' multiprocessing start method; supply a different mp_context.)r^rZr[r\r+T),r�r��	cpu_count�_max_workersr�r��min�_MAX_WINDOWS_WORKERSr�r�get_context�_mp_context�get_start_method�#_safe_to_dynamically_spawn_children�callable�	TypeError�_initializer�	_initargsrar�r��_executor_manager_threadr�r��	threading�Lockr��	Semaphorer�r��_queue_countr�r�rr��EXTRA_QUEUED_CALLSrXr��
_ignore_epipe�SimpleQueuer�r�rr�)r�max_workers�
mp_contextr�r�r��
queue_sizes       rrzProcessPoolExecutor.__init__zs���	�$	������ "���� 3�!�D���|�w�&�&�$'�(<�(,�(9�%;�%;��!���a��� �!E�F�F�F��,�'�)�)��2�2�2� �D�.B�D�D�F�F�F�!,�D����"�.��^�G�4�4�
�
��^�-�-�
�%���� �1�1�U�1�C�C�v�M�	
�0��"�8�K�+@�+@�"��<�=�=�=�'���!����*��1�3�7�7�
E�� H�I�I�I�$��)�)� �!C�D�D�D���0�0�E�0�B�B�f�L�L� �"C�D�D�D�%8��!�)-��%����!&���'�n�.�.���&/�&9�!�&<�&<��#�������#%�� �',��$�0=����,��&�);�;�
�%��T�%5�#�7��-��>�	@�@�@���*.���&�'�3�3�5�5����������rc���|j�^|js|���t|��|_|j���|jt|j<dSdSr)rr�_launch_processesr��startr�r'rs r�_start_executor_manager_threadz2ProcessPoolExecutor._start_executor_manager_thread�sn���(�0��;�
)��&�&�(�(�(�,B�4�,H�,H�D�)��)�/�/�1�1�1��4�
�T�:�;�;�;�
1�0rc��|j�d���rdSt|j��}||jkr|���dSdS)NF)�blocking)r��acquire�lenr�r	�_spawn_process)r�
process_counts  rr�z)ProcessPoolExecutor._adjust_process_count�sb���&�.�.��.�>�>�	��F��D�O�,�,�
��4�,�,�,�
���!�!�!�!�!�-�,rc��tt|j��|j��D]}|����dSr)r�r&r�r	r')rr*s  rr z%ProcessPoolExecutor._launch_processessI��
�s�4�?�+�+�T�->�?�?�	"�	"�A����!�!�!�!�	"�	"rc���|j�t|j|j|j|j|jf���}|���||j	|j
<dS)N)�targetrH)r
�Processr�r�r�rrr�r!r��pidr�s  rr'z"ProcessPoolExecutor._spawn_process	sg����$�$�"��"��$��#��.��+�	-�
%�
.�
.��	
���	�	�	�!"�������rc�,�|j5|jrt|j���|jrt	d���t
rt	d���t
j��}t||||��}||j	|j
<|j�|j
��|xj
dz
c_
|j
���|jr|���|���|cddd��S#1swxYwYdS)Nz*cannot schedule new futures after shutdownz6cannot schedule new futures after interpreter shutdownr.)r�r�r�r��RuntimeErrorr%r�FuturerDr�rr�r|r�rrr�r")rrGrHrI�f�ws      r�submitzProcessPoolExecutor.submitsg��
�
 �	�	��|�
6�'���5�5�5��$�
Q�"�#O�P�P�P��
;�"�$:�;�;�;�����A��!�R��v�.�.�A�:;�D�$�T�%6�7��N���t�0�1�1�1�����"����0�7�7�9�9�9��7�
-��*�*�,�,�,��/�/�1�1�1��+	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	s�C4D	�	D
�D
r.)�timeoutrpc����	|dkrtd���t���tt|��t|d|i�|���}t
|��S)Nr.zchunksize must be >= 1.rp)r4)r�r]�maprryrtr)rrGr4rprq�resultsr_s      �rr6zProcessPoolExecutor.map-sm���	�(�q�=�=��6�7�7�7��'�'�+�+�g�n�b�9�9�)�9�J�	�J�J�&-��/�/��-�W�5�5�5rTF)�cancel_futuresc�n�|j5||_d|_|j�|j���ddd��n#1swxYwY|j�|r|j���d|_d|_|j�|r|j�	��d|_d|_
d|_dSr)r�r�r�r�rrr)r�r�rr�)rr�r8s   r�shutdownzProcessPoolExecutor.shutdownJs��
�
 �	>�	>�+9�D�(�$(�D�!��3�?��4�;�;�=�=�=�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>�	>����	>�	>�	>�	>��(�4��4��)�.�.�0�0�0�)-��%������)�d�)���$�$�&�&�&�!������/3��,�,�,s�/A�A�
A)NNNr#)T)r r!r"rr"r�r r'r3r�Executor�__doc__r6r:rirjs@rrrys��������48�,.�l'�GK�l'�l'�l'�l'�l'�\5�5�5�
"�
"�
"�"�"�"�	#�	#�	#����.�^�*�2�F�N�*.�!�6�6�6�6�6�6�6�:4�E�4�4�4�4�4�(�~�.�6�H�����rrrSr)1�
__author__r��concurrent.futuresrr�r�r�multiprocessing.connection�multiprocessing.queuesrrr��	functoolsrrnr��	tracebackr�WeakKeyDictionaryr'r%rr-�_register_atexitrr�	Exceptionr1r8r?�objectrDrMrUrXrtryrr��Threadr�r�r�r�r�BrokenExecutorr�r;rr#rr�<module>rIsT��(�T2�
�	�	�	�	�$�$�$�$�$�$���������!�!�!�!�(�(�(�(�(�(�������������������
�
�
�
�&�&�&�&�&�&�-�7�,�.�.����*�*�*�*�*�*�*�*�4����	��<�(�(�(����������y����	1�	1�	1�	1�	1�	1�	1�	1�������������!�!�!�!�!�&�!�!�!����������3�3�3�3�3��3�3�3�2���	)�	)�	)�DH�"�	9�	9�	9�	9�3�3�3�3�lhB�hB�hB�hB�hB�Y�-�hB�hB�hB�V	����/�/�/�@	 �	 �	 �������,����e7�e7�e7�e7�e7�%�.�e7�e7�e7�e7�e7rfutures/__pycache__/__init__.cpython-311.opt-1.pyc000064400000002705152402271140015653 0ustar00�

UN�+�&b��R�dZdZddlmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
dZd�Zd�ZdS)z?Execute computations asynchronously using threads or processes.z"Brian Quinlan (brian@sweetapp.com)�)�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�CancelledError�TimeoutError�InvalidStateError�BrokenExecutor�Future�Executor�wait�as_completed)rrrrrr	r
rrr
�ProcessPoolExecutor�ThreadPoolExecutorc��tdzS)N)�
__author__�__doc__)�__all__���F/opt/alt/python-internal/lib/python3.11/concurrent/futures/__init__.py�__dir__r$s���.�.�.rc�v�|dkr
ddlm}|a|S|dkr
ddlm}|a|St	dt
�d|�����)Nr�)rr)rzmodule z has no attribute )�processr�threadr�AttributeError�__name__)�name�pe�tes   r�__getattr__r!(su���$�$�$�6�6�6�6�6�6� ���	��#�#�#�4�4�4�4�4�4����	�
�I�8�I�I��I�I�
J�
J�JrN)rr�concurrent.futures._baserrrrrrr	r
rrr
rrr!rrr�<module>r#s���F�E�
1�
�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
4�
�� /�/�/�
K�
K�
K�
K�
Krfutures/__pycache__/_base.cpython-311.opt-1.pyc000064400000110626152402271140015167 0ustar00�

��-8q'��
��dZddlZddlZddlZddlZddlZdZdZdZdZ	dZ
dZd	Zd
Z
dZe
eee
egZe
ded
ede
dediZejd��ZGd�de��ZGd�de��ZeZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�d e��Zd!�Zd"�Zd.d#�Z ej!d$d%��Z"defd&�Z#d.d'�Z$Gd(�d)e��Z%Gd*�d+e��Z&Gd,�d-e'��Z(dS)/z"Brian Quinlan (brian@sweetapp.com)�N�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�
_AS_COMPLETED�PENDING�RUNNING�	CANCELLED�CANCELLED_AND_NOTIFIED�FINISHED�pending�running�	cancelled�finishedzconcurrent.futuresc��eZdZdZdS)�Errorz-Base class for all future-related exceptions.N��__name__�
__module__�__qualname__�__doc__���C/opt/alt/python-internal/lib/python3.11/concurrent/futures/_base.pyrr-s������7�7��Drrc��eZdZdZdS)�CancelledErrorzThe Future was cancelled.Nrrrrrr1s������#�#��Drrc��eZdZdZdS)�InvalidStateErrorz+The operation is not allowed in this state.Nrrrrrr7s������5�5��Drrc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�_Waiterz;Provides the event that wait() and as_completed() block on.c�D�tj��|_g|_dS�N)�	threading�Event�event�finished_futures��selfs r�__init__z_Waiter.__init__=s���_�&�&��
� "����rc�:�|j�|��dSr!�r%�append�r'�futures  r�
add_resultz_Waiter.add_resultA�����$�$�V�,�,�,�,�,rc�:�|j�|��dSr!r*r,s  r�
add_exceptionz_Waiter.add_exceptionDr/rc�:�|j�|��dSr!r*r,s  r�
add_cancelledz_Waiter.add_cancelledGr/rN)rrrrr(r.r1r3rrrrr;sV������E�E�#�#�#�-�-�-�-�-�-�-�-�-�-�-rrc�@��eZdZdZ�fd�Z�fd�Z�fd�Z�fd�Z�xZS)�_AsCompletedWaiterzUsed by as_completed().c���tt|�����tj��|_dSr!)�superr5r(r"�Lock�lock)r'�	__class__s �rr(z_AsCompletedWaiter.__init__Ms3���
� �$�'�'�0�0�2�2�2��N�$�$��	�	�	rc����|j5tt|���|��|j���ddd��dS#1swxYwYdSr!)r9r7r5r.r$�set�r'r-r:s  �rr.z_AsCompletedWaiter.add_resultQs����
�Y�	�	��$�d�+�+�6�6�v�>�>�>��J�N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��AA�A�Ac����|j5tt|���|��|j���ddd��dS#1swxYwYdSr!)r9r7r5r1r$r<r=s  �rr1z _AsCompletedWaiter.add_exceptionV����
�Y�	�	��$�d�+�+�9�9�&�A�A�A��J�N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r>c����|j5tt|���|��|j���ddd��dS#1swxYwYdSr!)r9r7r5r3r$r<r=s  �rr3z _AsCompletedWaiter.add_cancelled[r@r>)	rrrrr(r.r1r3�
__classcell__�r:s@rr5r5Js��������!�!�%�%�%�%�%������
�����
��������rr5c�6��eZdZdZ�fd�Z�fd�Z�fd�Z�xZS)�_FirstCompletedWaiterz*Used by wait(return_when=FIRST_COMPLETED).c�|��t���|��|j���dSr!)r7r.r$r<r=s  �rr.z _FirstCompletedWaiter.add_resultcs3���
�����6�"�"�"��
�������rc�|��t���|��|j���dSr!)r7r1r$r<r=s  �rr1z#_FirstCompletedWaiter.add_exceptiong�3���
�����f�%�%�%��
�������rc�|��t���|��|j���dSr!)r7r3r$r<r=s  �rr3z#_FirstCompletedWaiter.add_cancelledkrHr)rrrrr.r1r3rBrCs@rrErE`sp�������4�4�������������������rrEc�F��eZdZdZ�fd�Zd�Z�fd�Z�fd�Z�fd�Z�xZ	S)�_AllCompletedWaiterz<Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED).c���||_||_tj��|_t�����dSr!)�num_pending_calls�stop_on_exceptionr"r8r9r7r()r'rMrNr:s   �rr(z_AllCompletedWaiter.__init__rs>���!2���!2����N�$�$��	�
���������rc��|j5|xjdzc_|js|j���ddd��dS#1swxYwYdS)N�)r9rMr$r<r&s r�_decrement_pending_callsz,_AllCompletedWaiter._decrement_pending_callsxs���
�Y�	!�	!��"�"�a�'�"�"��)�
!��
��� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�	!�	!s�1A�A
�
A
c�r��t���|��|���dSr!)r7r.rQr=s  �rr.z_AllCompletedWaiter.add_result~s3���
�����6�"�"�"��%�%�'�'�'�'�'rc���t���|��|jr|j���dS|���dSr!)r7r1rNr$r<rQr=s  �rr1z!_AllCompletedWaiter.add_exception�sV���
�����f�%�%�%��!�	,��J�N�N�������)�)�+�+�+�+�+rc�r��t���|��|���dSr!)r7r3rQr=s  �rr3z!_AllCompletedWaiter.add_cancelled�s3���
�����f�%�%�%��%�%�'�'�'�'�'r)
rrrrr(rQr.r1r3rBrCs@rrKrKos��������F�F������!�!�!�(�(�(�(�(�,�,�,�,�,�(�(�(�(�(�(�(�(�(rrKc�$�eZdZdZd�Zd�Zd�ZdS)�_AcquireFutureszDA context manager that does an ordered acquire of Future conditions.c�<�t|t���|_dS)N)�key)�sorted�id�futures)r'r[s  rr(z_AcquireFutures.__init__�s���g�2�.�.�.����rc�L�|jD]}|j����dSr!)r[�
_condition�acquirer,s  r�	__enter__z_AcquireFutures.__enter__��5���l�	(�	(�F���%�%�'�'�'�'�	(�	(rc�L�|jD]}|j����dSr!)r[r]�release)r'�argsr-s   r�__exit__z_AcquireFutures.__exit__�r`rN)rrrrr(r_rdrrrrVrV�sG������N�N�/�/�/�(�(�(�(�(�(�(�(rrVc�v�|tkrt��}n|tkrt��}net	d�|D����}|t
krt
|d���}n/|tkrt
|d���}ntd|z���|D]}|j	�
|���|S)Nc3�@K�|]}|jttfvV��dSr!��_stater
r��.0�fs  r�	<genexpr>z._create_and_install_waiters.<locals>.<genexpr>�sH����P�P�GH���!7�� B�B�P�P�P�P�P�PrT)rNFzInvalid return condition: %r)rr5rrE�sumrrKr�
ValueError�_waitersr+)�fs�return_when�waiter�
pending_countrks     r�_create_and_install_waitersrt�s����m�#�#�#�%�%���	��	'�	'�&�(�(����P�P�LN�P�P�P�P�P�
��/�)�)�(��$�O�O�O�F�F�
�M�
)�
)�(��%�P�P�P�F�F��;�k�I�J�J�J�
�"�"��	�
���&�!�!�!�!��Mrc#�K�|rv|d}|D]}|�|���|j5|j�|��ddd��n#1swxYwY~|���V�|�tdSdS)a~
    Iterate on the list *fs*, yielding finished futures one by one in
    reverse order.
    Before yielding a future, *waiter* is removed from its waiters
    and the future is removed from each set in the collection of sets
    *ref_collect*.

    The aim of this function is to avoid keeping stale references after
    the future is yielded and before the iterator resumes.
    ���N)�remover]ro�pop)rprr�ref_collectrk�futures_sets     r�_yield_finished_futuresr{�s�����
���r�F��&�	"�	"�K����q�!�!�!�!�
�\�	&�	&�
�J���f�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�
��f�f�h�h����
�����s�A�A�Ac	#�&K�|�|tj��z}t|��}t|��}t	|��5td�|D����}||z
}t|t��}ddd��n#1swxYwYt|��}	t|||f���Ed{V��|r�|�d}n=|tj��z
}|dkr!tdt|��|fz���|j
�|��|j5|j
}g|_
|j
���ddd��n#1swxYwY|���t||||f���Ed{V��|��|D];}|j5|j�|��ddd��n#1swxYwY�<dS#|D];}|j5|j�|��ddd��n#1swxYwY�<wxYw)anAn iterator over the given futures that yields each as it completes.

    Args:
        fs: The sequence of Futures (possibly created by different Executors) to
            iterate over.
        timeout: The maximum number of seconds to wait. If None, then there
            is no limit on the wait time.

    Returns:
        An iterator that yields the given Futures as they complete (finished or
        cancelled). If any given Futures are duplicated, they will be returned
        once.

    Raises:
        TimeoutError: If the entire result iterator could not be generated
            before the given timeout.
    Nc3�DK�|]}|jttfv�|V��dSr!rgris  rrlzas_completed.<locals>.<genexpr>�sE����C�C���8� 6��A�A�A��A�A�A�A�C�Cr)ryrz%d (of %d) futures unfinished)�time�	monotonicr<�lenrVrtr�listr{�TimeoutErrorr$�waitr9r%�clear�reverser]rorw)	rp�timeout�end_time�
total_futuresrrrr�wait_timeoutrks	         r�as_completedr��s�����$���T�^�-�-�-��	�R���B���G�G�M�	��	�	�@�@��C�C��C�C�C�C�C���x�-��,�R��?�?��@�@�@�@�@�@�@�@�@�@�@����@�@�@�@��H�~�~�H�*�*�8�V�8:�u�>�>�>�	>�	>�	>�	>�	>�	>�	>��	J���#���'�$�.�*:�*:�:���!�#�#�&�;���L�L�-�?9�9�:�:�:�
�L���l�+�+�+���
%�
%�!�2��*,��'���"�"�$�$�$�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%�
������.�x��<>��=�J�J�J�
J�
J�
J�
J�
J�
J�
J�'�	J�0�	*�	*�A���
*�
*��
�!�!�&�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��	*�	*���	*�	*�A���
*�
*��
�!�!�&�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��	*���sy�4B�B�B�#A>G�!(E�	G�E�G�E�3G�G�G	�	G	�H�H	�7H�H
�H�
H
�H�DoneAndNotDoneFuturesz
done not_donec��t|��}t|��5d�|D��}||z
}|tkr|rt||��cddd��S|tkr7|r5td�|D����rt||��cddd��St
|��t
|��krt||��cddd��St||��}ddd��n#1swxYwY|j�	|��|D];}|j
5|j�|��ddd��n#1swxYwY�<|�
|j��t|||z
��S)anWait for the futures in the given sequence to complete.

    Args:
        fs: The sequence of Futures (possibly created by different Executors) to
            wait upon.
        timeout: The maximum number of seconds to wait. If None, then there
            is no limit on the wait time.
        return_when: Indicates when this function should return. The options
            are:

            FIRST_COMPLETED - Return when any future finishes or is
                              cancelled.
            FIRST_EXCEPTION - Return when any future finishes by raising an
                              exception. If no future raises an exception
                              then it is equivalent to ALL_COMPLETED.
            ALL_COMPLETED -   Return when all futures finish or are cancelled.

    Returns:
        A named 2-tuple of sets. The first set, named 'done', contains the
        futures that completed (is finished or cancelled) before the wait
        completed. The second set, named 'not_done', contains uncompleted
        futures. Duplicate futures given to *fs* are removed and will be
        returned only once.
    c�<�h|]}|jttfv�|��Srrgris  r�	<setcomp>zwait.<locals>.<setcomp>"s7��F�F�F�a��h�#9�8�"D�D�D��D�D�DrNc3�jK�|].}|���s|����*|V��/dSr!)r�	exceptionris  rrlzwait.<locals>.<genexpr>(sP����G�G���+�+�-�-�G�,-�K�K�M�M�,E��,E�,E�,E�,E�G�Gr)r<rVrr�r�anyr�rtr$r�r]rorw�updater%)rpr�rq�done�not_donerrrks       rr�r�s���2

�R���B�	��	�	�>�>�F�F�2�F�F�F����9���?�*�*��*�(��x�8�8�>�>�>�>�>�>�>�>��_�,�,�$�,��G�G�d�G�G�G�G�G�
=�,�T�8�<�<�>�>�>�>�>�>�>�>��t�9�9��B�����(��x�8�8�>�>�>�>�>�>�>�>�-�R��=�=��>�>�>�>�>�>�>�>�>�>�>����>�>�>�>� �L���g����
�&�&��
�\�	&�	&�
�J���f�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&��	�K�K��'�(�(�(� ��r�D�y�1�1�1s5�.C4�5C4�/C4�C4�4C8�;C8�$E�E	�E	c��		|�|��|���~S#|���wxYw#~wxYwr!)�result�cancel)�futr�s  r�_result_or_cancelr�:sR���	��:�:�g�&�&��J�J�L�L�L�
�C��
�J�J�L�L�L�L�����
����s�-�A�A�A�A	c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
dd
�Zd�Zd�Zd�Zeej��ZdS)�Futurez5Represents the result of an asynchronous computation.c��tj��|_t|_d|_d|_g|_g|_dS)z8Initializes the future. Should not be called by clients.N)	r"�	Conditionr]rrh�_result�
_exceptionro�_done_callbacksr&s rr(zFuture.__init__Hs<��#�-�/�/��������������
�!����rc��|jD]9}	||���#t$rt�d|��Y�6wxYwdS)N�!exception calling callback for %r)r��	Exception�LOGGERr�)r'�callbacks  r�_invoke_callbackszFuture._invoke_callbacksQss���,�	L�	L�H�
L����������
L�
L�
L�� � �!D�d�K�K�K�K�K�
L����	L�	Ls��%?�?c��|j5|jtkr�|jrKd|jjt
|��t|j|jjjfzcddd��Sd|jjt
|��t|j|jjjfzcddd��Sd|jjt
|��t|jfzcddd��S#1swxYwYdS)Nz<%s at %#x state=%s raised %s>z <%s at %#x state=%s returned %s>z<%s at %#x state=%s>)	r]rhrr�r:rrZ�_STATE_TO_DESCRIPTION_MAPr�r&s r�__repr__zFuture.__repr__Xsh��
�_�	;�	;��{�h�&�&��?�9�;���/��4���1�$�+�>���1�:�	?<�<�	;�	;�	;�	;�	;�	;�	;�	;�>���/��4���1�$�+�>���.�7�	A9�9�	;�	;�	;�	;�	;�	;�	;�	;�*��N�+��t�H�H�,�T�[�9�-;�;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s�AC1�+>C1�6.C1�1C5�8C5c�B�|j5|jttfvr	ddd��dS|jtt
fvr	ddd��dSt|_|j���ddd��n#1swxYwY|���dS)z�Cancel the future if possible.

        Returns True if the future was cancelled, False otherwise. A future
        cannot be cancelled if it is running or has already completed.
        NFT)r]rhrrr	r
�
notify_allr�r&s rr�z
Future.cancells���_�	)�	)��{�w��1�1�1��	)�	)�	)�	)�	)�	)�	)�	)��{�y�*@�A�A�A��	)�	)�	)�	)�	)�	)�	)�	)�$�D�K��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � ��ts�B�B�%B�B�Bc�n�|j5|jttfvcddd��S#1swxYwYdS)z(Return True if the future was cancelled.N)r]rhr	r
r&s rrzFuture.cancelleds���
�_�	F�	F��;�9�.D�"E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�*�.�.c�d�|j5|jtkcddd��S#1swxYwYdS)z1Return True if the future is currently executing.N)r]rhrr&s rr
zFuture.running�sx��
�_�	*�	*��;�'�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s�%�)�)c�z�|j5|jtttfvcddd��S#1swxYwYdS)z>Return True if the future was cancelled or finished executing.N)r]rhr	r
rr&s rr�zFuture.done�s���
�_�	P�	P��;�9�.D�h�"O�O�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P�	P�	Ps�0�4�4c�<�|jr	|j�#d}wxYw|jSr!)r�r�r&s r�__get_resultzFuture.__get_result�s1���?�	 �
��o�%���������<�s��c�<�|j5|jtttfvr(|j�|��	ddd��dS	ddd��n#1swxYwY	||��dS#t$rt�	d|��YdSwxYw)a%Attaches a callable that will be called when the future finishes.

        Args:
            fn: A callable that will be called with this future as its only
                argument when the future completes or is cancelled. The callable
                will always be called by a thread in the same process in which
                it was added. If the future has already completed or been
                cancelled then the callable will be called immediately. These
                callables are called in the order that they were added.
        Nr�)
r]rhr	r
rr�r+r�r�r�)r'�fns  r�add_done_callbackzFuture.add_done_callback�s���_�	�	��{�9�.D�h�"O�O�O��$�+�+�B�/�/�/��	�	�	�	�	�	�	�	�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	H��B�t�H�H�H�H�H���	H�	H�	H����@�$�G�G�G�G�G�G�	H���s#�7A�A� A�%A2�2%B�BNc���	|j5|jttfvrt	���|jt
kr"|���cddd��d}S|j�|��|jttfvrt	���|jt
kr"|���cddd��d}St���#1swxYwY	d}dS#d}wxYw)aBReturn the result of the call that the future represents.

        Args:
            timeout: The number of seconds to wait for the result if the future
                isn't done. If None, then there is no limit on the wait time.

        Returns:
            The result of the call that the future represents.

        Raises:
            CancelledError: If the future was cancelled.
            TimeoutError: If the future didn't finish executing before the given
                timeout.
            Exception: If the call raised then that exception will be raised.
        N)	r]rhr	r
rr�_Future__get_resultr�r��r'r�s  rr�z
Future.result�sP�� 	���

)�

)��;�9�.D�"E�E�E�(�*�*�*��[�H�,�,��,�,�.�.�	

)�

)�

)�

)�

)�

)�

)� �D�D���$�$�W�-�-�-��;�9�.D�"E�E�E�(�*�*�*��[�H�,�,��,�,�.�.�

)�

)�

)�

)�

)�

)�

)� �D�D�'�.�.�(�

)�

)�

)�

)����

)�

)�

)�

)�

)� �D�D�D��4�D�K�K�K�KsB�C,�AC�C,�A C�?C,�C�C � C,�#C �$C,�,C0c��|j5|jttfvrt	���|jt
kr|jcddd��S|j�|��|jttfvrt	���|jt
kr|jcddd��St���#1swxYwYdS)aUReturn the exception raised by the call that the future represents.

        Args:
            timeout: The number of seconds to wait for the exception if the
                future isn't done. If None, then there is no limit on the wait
                time.

        Returns:
            The exception raised by the call that the future represents or None
            if the call completed without raising.

        Raises:
            CancelledError: If the future was cancelled.
            TimeoutError: If the future didn't finish executing before the given
                timeout.
        N)	r]rhr	r
rrr�r�r�r�s  rr�zFuture.exception�s��$�_�
	%�
	%��{�y�*@�A�A�A�$�&�&�&����(�(���	
	%�
	%�
	%�
	%�
	%�
	%�
	%�
	%�
�O� � ��)�)�)��{�y�*@�A�A�A�$�&�&�&����(�(���
	%�
	%�
	%�
	%�
	%�
	%�
	%�
	%�#�n�n�$�
	%�
	%�
	%�
	%����
	%�
	%�
	%�
	%�
	%�
	%s�:B=�AB=�/B=�=C�Cc��|j5|jtkr9t|_|jD]}|�|���	ddd��dS|jtkrt|_	ddd��dSt�	dt|��|j��td���#1swxYwYdS)a�Mark the future as running or process any cancel notifications.

        Should only be used by Executor implementations and unit tests.

        If the future has been cancelled (cancel() was called and returned
        True) then any threads waiting on the future completing (though calls
        to as_completed() or wait()) are notified and False is returned.

        If the future was not cancelled then it is put in the running state
        (future calls to running() will return True) and True is returned.

        This method should be called by Executor implementations before
        executing the work associated with this future. If this method returns
        False then the work should not be executed.

        Returns:
            False if the Future was cancelled, True otherwise.

        Raises:
            RuntimeError: if this method was already called or if set_result()
                or set_exception() was called.
        NFTz!Future %s in unexpected state: %szFuture in unexpected state)r]rhr	r
ror3rrr��criticalrZ�RuntimeError)r'rrs  r�set_running_or_notify_cancelz#Future.set_running_or_notify_cancel�sH��.�_�	A�	A��{�i�'�'�4���"�m�/�/�F��(�(��.�.�.�.��	A�	A�	A�	A�	A�	A�	A�	A����'�'�%����	A�	A�	A�	A�	A�	A�	A�	A���� C� "�4��� $��-�-�-�#�#?�@�@�@�	A�	A�	A�	A����	A�	A�	A�	A�	A�	As�=B9�B9�<=B9�9B=�B=c��|j5|jttthvr(td�|j|�����||_t|_|jD]}|�	|���|j�
��ddd��n#1swxYwY|���dS)z�Sets the return value of work associated with the future.

        Should only be used by Executor implementations and unit tests.
        �{}: {!r}N)r]rhr	r
rr�formatr�ror.r�r�)r'r�rrs   r�
set_resultzFuture.set_results���
�_�	)�	)��{�y�*@�(�K�K�K�'�
�(9�(9�$�+�t�(L�(L�M�M�M�!�D�L�"�D�K��-�
(�
(���!�!�$�'�'�'�'��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � � � ��BB#�#B'�*B'c��|j5|jttthvr(td�|j|�����||_t|_|jD]}|�	|���|j�
��ddd��n#1swxYwY|���dS)z�Sets the result of the future as being the given exception.

        Should only be used by Executor implementations and unit tests.
        r�N)r]rhr	r
rrr�r�ror1r�r�)r'r�rrs   r�
set_exceptionzFuture.set_exception(s���
�_�	)�	)��{�y�*@�(�K�K�K�'�
�(9�(9�$�+�t�(L�(L�M�M�M�'�D�O�"�D�K��-�
+�
+���$�$�T�*�*�*�*��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � � � r�r!)rrrrr(r�r�r�rr
r�r�r�r�r�r�r�r��classmethod�types�GenericAlias�__class_getitem__rrrr�r�Es������?�?�"�"�"�L�L�L�;�;�;�(���&F�F�F�
*�*�*�
P�P�P�
 � � �H�H�H�(!�!�!�!�F%�%�%�%�D&A�&A�&A�P
!�
!�
!�
!�
!�
!�$��E�$6�7�7���rr�c�@�eZdZdZd�Zddd�d�Zd
dd	�d
�Zd�Zd�ZdS)�ExecutorzCThis is an abstract base class for concrete asynchronous executors.c��t���)a Submits a callable to be executed with the given arguments.

        Schedules the callable to be executed as fn(*args, **kwargs) and returns
        a Future instance representing the execution of the callable.

        Returns:
            A Future representing the given call.
        )�NotImplementedError)r'r�rc�kwargss    r�submitzExecutor.submit<s��"�#�#�#rNrP)r��	chunksizec����������tj��z���fd�t|�D������fd�}|��S)a}Returns an iterator equivalent to map(fn, iter).

        Args:
            fn: A callable that will take as many arguments as there are
                passed iterables.
            timeout: The maximum number of seconds to wait. If None, then there
                is no limit on the wait time.
            chunksize: The size of the chunks the iterable will be broken into
                before being passed to a child process. This argument is only
                used by ProcessPoolExecutor; it is ignored by
                ThreadPoolExecutor.

        Returns:
            An iterator equivalent to: map(func, *iterables) but the calls may
            be evaluated out-of-order.

        Raises:
            TimeoutError: If the entire result iterator could not be generated
                before the given timeout.
            Exception: If fn(*args) raises for any values.
        Nc�,��g|]}�j�g|�R���Sr)r�)rjrcr�r's  ��r�
<listcomp>z Executor.map.<locals>.<listcomp>`s-���
A�
A�
A��k�d�k�"�$�t�$�$�$�
A�
A�
Arc3�h�K�	�����r`��$t������V�n8t�����tj��z
��V���`�D]}|����dS#�D]}|����wxYwr!)r�r�rxr~rr�)r-r�rpr�s ���r�result_iteratorz%Executor.map.<locals>.result_iteratords������
$��
�
�����W���/������9�9�9�9�9�9�/������(�T�^�EU�EU�:U�V�V�V�V�V��W�!�$�$�F��M�M�O�O�O�O�$�$��b�$�$�F��M�M�O�O�O�O�$���s�A6B�B1)r~r�zip)r'r�r�r��	iterablesr�r�rps```   @@r�mapzExecutor.mapGst�������,�����!1�!1�1�H�
A�
A�
A�
A�
A��i��
A�
A�
A��	$�	$�	$�	$�	$�	$�	$��� � � rTF)�cancel_futuresc��dS)a;Clean-up the resources associated with the Executor.

        It is safe to call this method several times. Otherwise, no other
        methods can be called after this one.

        Args:
            wait: If True then shutdown will not return until all running
                futures have finished executing and the resources used by the
                executor have been reclaimed.
            cancel_futures: If True then shutdown will cancel all pending
                futures. Futures that are completed or running will not be
                cancelled.
        Nr)r'r�r�s   r�shutdownzExecutor.shutdownss	��	
�rc��|Sr!rr&s rr_zExecutor.__enter__�s���rc�2�|�d���dS)NT)r�F)r�)r'�exc_type�exc_val�exc_tbs    rrdzExecutor.__exit__�s���
�
�4�
� � � ��ur)T)	rrrrr�r�r�r_rdrrrr�r�9s�������M�M�	$�	$�	$�+/�!�*!�*!�*!�*!�*!�X
�E�
�
�
�
�
� �������rr�c��eZdZdZdS)�BrokenExecutorzR
    Raised when a executor has become non-functional after a severe failure.
    Nrrrrr�r��s���������rr�r!))�
__author__�collections�loggingr"r~r�rrrrrrr	r
r�_FUTURE_STATESr��	getLoggerr�r�rrr�r�objectrr5rErKrVrtr{r��
namedtupler�r�r�r�r�r�r�rrr�<module>r�s-��2�
���������������������#��#���
��
���
���	�1������
������Y��Y�
�{��K��j���
��	�/�	0�	0��	�	�	�	�	�I�	�	�	�	�	�	�	�	�U�	�	�	���	�	�	�	�	��	�	�	�
-�
-�
-�
-�
-�f�
-�
-�
-����������,
�
�
�
�
�G�
�
�
�(�(�(�(�(�'�(�(�(�<(�(�(�(�(�f�(�(�(����,���,<*�<*�<*�<*�|/��.���2�2���}�02�02�02�02�f����r8�r8�r8�r8�r8�V�r8�r8�r8�hO�O�O�O�O�v�O�O�O�d�����\�����rfutures/__pycache__/_base.cpython-311.opt-2.pyc000064400000071317152402271140015173 0ustar00�

��-8q'��
��dZddlZddlZddlZddlZddlZdZdZdZdZ	dZ
dZd	Zd
Z
dZe
eee
egZe
ded
ede
dediZejd��ZGd�de��ZGd�de��ZeZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�d e��Zd!�Zd"�Zd.d#�Z ej!d$d%��Z"defd&�Z#d.d'�Z$Gd(�d)e��Z%Gd*�d+e��Z&Gd,�d-e'��Z(dS)/z"Brian Quinlan (brian@sweetapp.com)�N�FIRST_COMPLETED�FIRST_EXCEPTION�
ALL_COMPLETED�
_AS_COMPLETED�PENDING�RUNNING�	CANCELLED�CANCELLED_AND_NOTIFIED�FINISHED�pending�running�	cancelled�finishedzconcurrent.futuresc��eZdZ	dS)�ErrorN��__name__�
__module__�__qualname__���C/opt/alt/python-internal/lib/python3.11/concurrent/futures/_base.pyrr-s������7��Drrc��eZdZ	dS)�CancelledErrorNrrrrrr1s������#��Drrc��eZdZ	dS)�InvalidStateErrorNrrrrrr7s������5��Drrc�(�eZdZ	d�Zd�Zd�Zd�ZdS)�_Waiterc�D�tj��|_g|_dS�N)�	threading�Event�event�finished_futures��selfs r�__init__z_Waiter.__init__=s���_�&�&��
� "����rc�:�|j�|��dSr �r$�append�r&�futures  r�
add_resultz_Waiter.add_resultA�����$�$�V�,�,�,�,�,rc�:�|j�|��dSr r)r+s  r�
add_exceptionz_Waiter.add_exceptionDr.rc�:�|j�|��dSr r)r+s  r�
add_cancelledz_Waiter.add_cancelledGr.rN)rrrr'r-r0r2rrrrr;sS������E�#�#�#�-�-�-�-�-�-�-�-�-�-�-rrc�>��eZdZ	�fd�Z�fd�Z�fd�Z�fd�Z�xZS)�_AsCompletedWaiterc���tt|�����tj��|_dSr )�superr4r'r!�Lock�lock)r&�	__class__s �rr'z_AsCompletedWaiter.__init__Ms3���
� �$�'�'�0�0�2�2�2��N�$�$��	�	�	rc����|j5tt|���|��|j���ddd��dS#1swxYwYdSr )r8r6r4r-r#�set�r&r,r9s  �rr-z_AsCompletedWaiter.add_resultQs����
�Y�	�	��$�d�+�+�6�6�v�>�>�>��J�N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	��AA�A�Ac����|j5tt|���|��|j���ddd��dS#1swxYwYdSr )r8r6r4r0r#r;r<s  �rr0z _AsCompletedWaiter.add_exceptionV����
�Y�	�	��$�d�+�+�9�9�&�A�A�A��J�N�N����	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r=c����|j5tt|���|��|j���ddd��dS#1swxYwYdSr )r8r6r4r2r#r;r<s  �rr2z _AsCompletedWaiter.add_cancelled[r?r=)rrrr'r-r0r2�
__classcell__�r9s@rr4r4Js��������!�%�%�%�%�%������
�����
��������rr4c�4��eZdZ	�fd�Z�fd�Z�fd�Z�xZS)�_FirstCompletedWaiterc�|��t���|��|j���dSr )r6r-r#r;r<s  �rr-z _FirstCompletedWaiter.add_resultcs3���
�����6�"�"�"��
�������rc�|��t���|��|j���dSr )r6r0r#r;r<s  �rr0z#_FirstCompletedWaiter.add_exceptiong�3���
�����f�%�%�%��
�������rc�|��t���|��|j���dSr )r6r2r#r;r<s  �rr2z#_FirstCompletedWaiter.add_cancelledkrGr)rrrr-r0r2rArBs@rrDrD`sm�������4�������������������rrDc�D��eZdZ	�fd�Zd�Z�fd�Z�fd�Z�fd�Z�xZS)�_AllCompletedWaiterc���||_||_tj��|_t�����dSr )�num_pending_calls�stop_on_exceptionr!r7r8r6r')r&rLrMr9s   �rr'z_AllCompletedWaiter.__init__rs>���!2���!2����N�$�$��	�
���������rc��|j5|xjdzc_|js|j���ddd��dS#1swxYwYdS)N�)r8rLr#r;r%s r�_decrement_pending_callsz,_AllCompletedWaiter._decrement_pending_callsxs���
�Y�	!�	!��"�"�a�'�"�"��)�
!��
��� � � �	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!�	!�	!s�1A�A
�
A
c�r��t���|��|���dSr )r6r-rPr<s  �rr-z_AllCompletedWaiter.add_result~s3���
�����6�"�"�"��%�%�'�'�'�'�'rc���t���|��|jr|j���dS|���dSr )r6r0rMr#r;rPr<s  �rr0z!_AllCompletedWaiter.add_exception�sV���
�����f�%�%�%��!�	,��J�N�N�������)�)�+�+�+�+�+rc�r��t���|��|���dSr )r6r2rPr<s  �rr2z!_AllCompletedWaiter.add_cancelled�s3���
�����f�%�%�%��%�%�'�'�'�'�'r)	rrrr'rPr-r0r2rArBs@rrJrJos��������F������!�!�!�(�(�(�(�(�,�,�,�,�,�(�(�(�(�(�(�(�(�(rrJc�"�eZdZ	d�Zd�Zd�ZdS)�_AcquireFuturesc�<�t|t���|_dS)N)�key)�sorted�id�futures)r&rZs  rr'z_AcquireFutures.__init__�s���g�2�.�.�.����rc�L�|jD]}|j����dSr )rZ�
_condition�acquirer+s  r�	__enter__z_AcquireFutures.__enter__��5���l�	(�	(�F���%�%�'�'�'�'�	(�	(rc�L�|jD]}|j����dSr )rZr\�release)r&�argsr,s   r�__exit__z_AcquireFutures.__exit__�r_rN)rrrr'r^rcrrrrUrU�sD������N�/�/�/�(�(�(�(�(�(�(�(rrUc�v�|tkrt��}n|tkrt��}net	d�|D����}|t
krt
|d���}n/|tkrt
|d���}ntd|z���|D]}|j	�
|���|S)Nc3�@K�|]}|jttfvV��dSr ��_stater
r��.0�fs  r�	<genexpr>z._create_and_install_waiters.<locals>.<genexpr>�sH����P�P�GH���!7�� B�B�P�P�P�P�P�PrT)rMFzInvalid return condition: %r)rr4rrD�sumrrJr�
ValueError�_waitersr*)�fs�return_when�waiter�
pending_countrjs     r�_create_and_install_waitersrs�s����m�#�#�#�%�%���	��	'�	'�&�(�(����P�P�LN�P�P�P�P�P�
��/�)�)�(��$�O�O�O�F�F�
�M�
)�
)�(��%�P�P�P�F�F��;�k�I�J�J�J�
�"�"��	�
���&�!�!�!�!��Mrc#�K�	|rv|d}|D]}|�|���|j5|j�|��ddd��n#1swxYwY~|���V�|�tdSdS)N���)�remover\rn�pop)rorq�ref_collectrj�futures_sets     r�_yield_finished_futuresrz�s�����	�
���r�F��&�	"�	"�K����q�!�!�!�!�
�\�	&�	&�
�J���f�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&�
��f�f�h�h����
�����s�A�A�Ac	#�(K�	|�|tj��z}t|��}t|��}t	|��5td�|D����}||z
}t|t��}ddd��n#1swxYwYt|��}	t|||f���Ed{V��|r�|�d}n=|tj��z
}|dkr!tdt|��|fz���|j
�|��|j5|j
}g|_
|j
���ddd��n#1swxYwY|���t||||f���Ed{V��|��|D];}|j5|j�|��ddd��n#1swxYwY�<dS#|D];}|j5|j�|��ddd��n#1swxYwY�<wxYw)Nc3�DK�|]}|jttfv�|V��dSr rfrhs  rrkzas_completed.<locals>.<genexpr>�sE����C�C���8� 6��A�A�A��A�A�A�A�C�Cr)rxrz%d (of %d) futures unfinished)�time�	monotonicr;�lenrUrsr�listrz�TimeoutErrorr#�waitr8r$�clear�reverser\rnrv)	ro�timeout�end_time�
total_futuresrrrq�wait_timeoutrjs	         r�as_completedr��s������"���T�^�-�-�-��	�R���B���G�G�M�	��	�	�@�@��C�C��C�C�C�C�C���x�-��,�R��?�?��@�@�@�@�@�@�@�@�@�@�@����@�@�@�@��H�~�~�H�*�*�8�V�8:�u�>�>�>�	>�	>�	>�	>�	>�	>�	>��	J���#���'�$�.�*:�*:�:���!�#�#�&�;���L�L�-�?9�9�:�:�:�
�L���l�+�+�+���
%�
%�!�2��*,��'���"�"�$�$�$�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%�
������.�x��<>��=�J�J�J�
J�
J�
J�
J�
J�
J�
J�'�	J�0�	*�	*�A���
*�
*��
�!�!�&�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��	*�	*���	*�	*�A���
*�
*��
�!�!�&�)�)�)�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*��	*���sy�	4B	�	B
�B
�$A>G�"(E�
G�E�G�E�3G�G�G	�
G	�H�H	�8H�H
�H�H
�H�DoneAndNotDoneFuturesz
done not_donec�
�	t|��}t|��5d�|D��}||z
}|tkr|rt||��cddd��S|tkr7|r5td�|D����rt||��cddd��St
|��t
|��krt||��cddd��St||��}ddd��n#1swxYwY|j�	|��|D];}|j
5|j�|��ddd��n#1swxYwY�<|�
|j��t|||z
��S)Nc�<�h|]}|jttfv�|��Srrfrhs  r�	<setcomp>zwait.<locals>.<setcomp>"s7��F�F�F�a��h�#9�8�"D�D�D��D�D�Drc3�jK�|].}|���s|����*|V��/dSr )r�	exceptionrhs  rrkzwait.<locals>.<genexpr>(sP����G�G���+�+�-�-�G�,-�K�K�M�M�,E��,E�,E�,E�,E�G�Gr)r;rUrr�r�anyrrsr#r�r\rnrv�updater$)ror�rp�done�not_donerqrjs       rr�r�s����0

�R���B�	��	�	�>�>�F�F�2�F�F�F����9���?�*�*��*�(��x�8�8�>�>�>�>�>�>�>�>��_�,�,�$�,��G�G�d�G�G�G�G�G�
=�,�T�8�<�<�>�>�>�>�>�>�>�>��t�9�9��B�����(��x�8�8�>�>�>�>�>�>�>�>�-�R��=�=��>�>�>�>�>�>�>�>�>�>�>����>�>�>�>� �L���g����
�&�&��
�\�	&�	&�
�J���f�%�%�%�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&�	&����	&�	&�	&�	&��	�K�K��'�(�(�(� ��r�D�y�1�1�1s5�.C5�5C5�/C5�C5�5C9�<C9�%E�E	�E	c��		|�|��|���~S#|���wxYw#~wxYwr )�result�cancel)�futr�s  r�_result_or_cancelr�:sR���	��:�:�g�&�&��J�J�L�L�L�
�C��
�J�J�L�L�L�L�����
����s�-�A�A�A�A	c��eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd�Zdd�Z
d
�Zd�Zd�Zeej��Zd
S)�Futurec��	tj��|_t|_d|_d|_g|_g|_dSr )	r!�	Conditionr\rrg�_result�
_exceptionrn�_done_callbacksr%s rr'zFuture.__init__Hs?��F�#�-�/�/��������������
�!����rc��|jD]9}	||���#t$rt�d|��Y�6wxYwdS�Nz!exception calling callback for %r)r��	Exception�LOGGERr�)r&�callbacks  r�_invoke_callbackszFuture._invoke_callbacksQss���,�	L�	L�H�
L����������
L�
L�
L�� � �!D�d�K�K�K�K�K�
L����	L�	Ls��%?�?c��|j5|jtkr�|jrKd|jjt
|��t|j|jjjfzcddd��Sd|jjt
|��t|j|jjjfzcddd��Sd|jjt
|��t|jfzcddd��S#1swxYwYdS)Nz<%s at %#x state=%s raised %s>z <%s at %#x state=%s returned %s>z<%s at %#x state=%s>)	r\rgrr�r9rrY�_STATE_TO_DESCRIPTION_MAPr�r%s r�__repr__zFuture.__repr__Xsh��
�_�	;�	;��{�h�&�&��?�9�;���/��4���1�$�+�>���1�:�	?<�<�	;�	;�	;�	;�	;�	;�	;�	;�>���/��4���1�$�+�>���.�7�	A9�9�	;�	;�	;�	;�	;�	;�	;�	;�*��N�+��t�H�H�,�T�[�9�-;�;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;�	;����	;�	;�	;�	;�	;�	;s�AC1�+>C1�6.C1�1C5�8C5c�D�	|j5|jttfvr	ddd��dS|jtt
fvr	ddd��dSt|_|j���ddd��n#1swxYwY|���dS)NFT)r\rgrrr	r
�
notify_allr�r%s rr�z
Future.cancells��	�
�_�	)�	)��{�w��1�1�1��	)�	)�	)�	)�	)�	)�	)�	)��{�y�*@�A�A�A��	)�	)�	)�	)�	)�	)�	)�	)�$�D�K��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � ��ts�B�B�%B�B�Bc�p�	|j5|jttfvcddd��S#1swxYwYdSr )r\rgr	r
r%s rrzFuture.cancelleds���6�
�_�	F�	F��;�9�.D�"E�E�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F�	F����	F�	F�	F�	F�	F�	Fs�+�/�/c�f�	|j5|jtkcddd��S#1swxYwYdSr )r\rgrr%s rr
zFuture.running�s{��?�
�_�	*�	*��;�'�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s�&�*�*c�|�	|j5|jtttfvcddd��S#1swxYwYdSr )r\rgr	r
rr%s rr�zFuture.done�s���L�
�_�	P�	P��;�9�.D�h�"O�O�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P�	P����	P�	P�	P�	P�	P�	Ps�1�5�5c�<�|jr	|j�#d}wxYw|jSr )r�r�r%s r�__get_resultzFuture.__get_result�s1���?�	 �
��o�%���������<�s��c�>�	|j5|jtttfvr(|j�|��	ddd��dS	ddd��n#1swxYwY	||��dS#t$rt�	d|��YdSwxYwr�)
r\rgr	r
rr�r*r�r�r�)r&�fns  r�add_done_callbackzFuture.add_done_callback�s��		��_�	�	��{�9�.D�h�"O�O�O��$�+�+�B�/�/�/��	�	�	�	�	�	�	�	�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	H��B�t�H�H�H�H�H���	H�	H�	H����@�$�G�G�G�G�G�G�	H���s#�7A�A�!A�&A3�3%B�BNc���		|j5|jttfvrt	���|jt
kr"|���cddd��d}S|j�|��|jttfvrt	���|jt
kr"|���cddd��d}St���#1swxYwY	d}dS#d}wxYwr )	r\rgr	r
rr�_Future__get_resultr�r��r&r�s  rr�z
Future.result�sU��	�	���

)�

)��;�9�.D�"E�E�E�(�*�*�*��[�H�,�,��,�,�.�.�	

)�

)�

)�

)�

)�

)�

)� �D�D���$�$�W�-�-�-��;�9�.D�"E�E�E�(�*�*�*��[�H�,�,��,�,�.�.�

)�

)�

)�

)�

)�

)�

)� �D�D�'�.�.�(�

)�

)�

)�

)����

)�

)�

)�

)�

)� �D�D�D��4�D�K�K�K�KsB�C-�AC�C-� A C�C-�C�C!�!C-�$C!�%C-�-C1c��	|j5|jttfvrt	���|jt
kr|jcddd��S|j�|��|jttfvrt	���|jt
kr|jcddd��St���#1swxYwYdSr )	r\rgr	r
rrr�r�r�r�s  rr�zFuture.exception�s#��	�"�_�
	%�
	%��{�y�*@�A�A�A�$�&�&�&����(�(���	
	%�
	%�
	%�
	%�
	%�
	%�
	%�
	%�
�O� � ��)�)�)��{�y�*@�A�A�A�$�&�&�&����(�(���
	%�
	%�
	%�
	%�
	%�
	%�
	%�
	%�#�n�n�$�
	%�
	%�
	%�
	%����
	%�
	%�
	%�
	%�
	%�
	%s�:B>�AB>�0B>�>C�Cc��	|j5|jtkr9t|_|jD]}|�|���	ddd��dS|jtkrt|_	ddd��dSt�	dt|��|j��td���#1swxYwYdS)NFTz!Future %s in unexpected state: %szFuture in unexpected state)r\rgr	r
rnr2rrr��criticalrY�RuntimeError)r&rqs  r�set_running_or_notify_cancelz#Future.set_running_or_notify_cancel�sM��	�,�_�	A�	A��{�i�'�'�4���"�m�/�/�F��(�(��.�.�.�.��	A�	A�	A�	A�	A�	A�	A�	A����'�'�%����	A�	A�	A�	A�	A�	A�	A�	A���� C� "�4��� $��-�-�-�#�#?�@�@�@�	A�	A�	A�	A����	A�	A�	A�	A�	A�	As�=B:�B:�==B:�:B>�B>c��	|j5|jttthvr(td�|j|�����||_t|_|jD]}|�	|���|j�
��ddd��n#1swxYwY|���dS�Nz{}: {!r})r\rgr	r
rr�formatr�rnr-r�r�)r&r�rqs   r�
set_resultzFuture.set_results���	��_�	)�	)��{�y�*@�(�K�K�K�'�
�(9�(9�$�+�t�(L�(L�M�M�M�!�D�L�"�D�K��-�
(�
(���!�!�$�'�'�'�'��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � � � ��BB$�$B(�+B(c��	|j5|jttthvr(td�|j|�����||_t|_|jD]}|�	|���|j�
��ddd��n#1swxYwY|���dSr�)r\rgr	r
rrr�r�rnr0r�r�)r&r�rqs   r�
set_exceptionzFuture.set_exception(s���	��_�	)�	)��{�y�*@�(�K�K�K�'�
�(9�(9�$�+�t�(L�(L�M�M�M�'�D�O�"�D�K��-�
+�
+���$�$�T�*�*�*�*��O�&�&�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	
��� � � � � r�r )rrrr'r�r�r�rr
r�r�r�r�r�r�r�r��classmethod�types�GenericAlias�__class_getitem__rrrr�r�Es������?�"�"�"�L�L�L�;�;�;�(���&F�F�F�
*�*�*�
P�P�P�
 � � �H�H�H�(!�!�!�!�F%�%�%�%�D&A�&A�&A�P
!�
!�
!�
!�
!�
!�$��E�$6�7�7���rr�c�>�eZdZ	d�Zddd�d�Zddd�d	�Zd
�Zd�ZdS)
�Executorc� �	t���r )�NotImplementedError)r&r�rb�kwargss    r�submitzExecutor.submit<s��	�"�#�#�#rNrO)r��	chunksizec�������	���tj��z���fd�t|�D������fd�}|��S)Nc�,��g|]}�j�g|�R���Sr)r�)rirbr�r&s  ��r�
<listcomp>z Executor.map.<locals>.<listcomp>`s-���
A�
A�
A��k�d�k�"�$�t�$�$�$�
A�
A�
Arc3�h�K�	�����r`��$t������V�n8t�����tj��z
��V���`�D]}|����dS#�D]}|����wxYwr )r�r�rwr}r~r�)r,r�ror�s ���r�result_iteratorz%Executor.map.<locals>.result_iteratords������
$��
�
�����W���/������9�9�9�9�9�9�/������(�T�^�EU�EU�:U�V�V�V�V�V��W�!�$�$�F��M�M�O�O�O�O�$�$��b�$�$�F��M�M�O�O�O�O�$���s�A6B�B1)r}r~�zip)r&r�r�r��	iterablesr�r�ros```   @@r�mapzExecutor.mapGsy�������	�*�����!1�!1�1�H�
A�
A�
A�
A�
A��i��
A�
A�
A��	$�	$�	$�	$�	$�	$�	$��� � � rTF)�cancel_futuresc��	dSr r)r&r�r�s   r�shutdownzExecutor.shutdownss��	�	
�rc��|Sr rr%s rr^zExecutor.__enter__�s���rc�2�|�d���dS)NT)r�F)r�)r&�exc_type�exc_val�exc_tbs    rrczExecutor.__exit__�s���
�
�4�
� � � ��ur)T)rrrr�r�r�r^rcrrrr�r�9s�������M�	$�	$�	$�+/�!�*!�*!�*!�*!�*!�X
�E�
�
�
�
�
� �������rr�c��eZdZdS)�BrokenExecutorNrrrrr�r��s�������rr�r ))�
__author__�collections�loggingr!r}r�rrrrrrr	r
r�_FUTURE_STATESr��	getLoggerr�r�rrr�r�objectrr4rDrJrUrsrzr��
namedtupler�r�r�r�r�r�r�rrr�<module>r�s-��2�
���������������������#��#���
��
���
���	�1������
������Y��Y�
�{��K��j���
��	�/�	0�	0��	�	�	�	�	�I�	�	�	�	�	�	�	�	�U�	�	�	���	�	�	�	�	��	�	�	�
-�
-�
-�
-�
-�f�
-�
-�
-����������,
�
�
�
�
�G�
�
�
�(�(�(�(�(�'�(�(�(�<(�(�(�(�(�f�(�(�(����,���,<*�<*�<*�<*�|/��.���2�2���}�02�02�02�02�f����r8�r8�r8�r8�r8�V�r8�r8�r8�hO�O�O�O�O�v�O�O�O�d�����\�����r__pycache__/__init__.cpython-311.pyc000064400000000253152402271140013213 0ustar00�

c��]/����dS)N�r��>/opt/alt/python-internal/lib/python3.11/concurrent/__init__.py�<module>rs���r__pycache__/__init__.cpython-311.opt-2.pyc000064400000000253152402271140014153 0ustar00�

c��]/����dS)N�r��>/opt/alt/python-internal/lib/python3.11/concurrent/__init__.py�<module>rs���r__pycache__/__init__.cpython-311.opt-1.pyc000064400000000253152402271140014152 0ustar00�

c��]/����dS)N�r��>/opt/alt/python-internal/lib/python3.11/concurrent/__init__.py�<module>rs���r