prefect-client 3.1.5__tar.gz → 3.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prefect-client-3.1.5 → prefect-client-3.1.6}/MANIFEST.in +3 -3
- {prefect-client-3.1.5/src/prefect_client.egg-info → prefect-client-3.1.6}/PKG-INFO +4 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/README.md +3 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/setup.cfg +1 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/__init__.py +3 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/compatibility/migration.py +1 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/api.py +52 -52
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/calls.py +59 -35
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/cancellation.py +34 -18
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/event_loop.py +7 -6
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/threads.py +41 -33
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/waiters.py +28 -21
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pydantic/v1_schema.py +2 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pydantic/v2_schema.py +10 -9
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/schemas/bases.py +9 -7
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/schemas/validators.py +2 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_version.py +3 -3
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/automations.py +53 -47
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/abstract.py +12 -10
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/core.py +4 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/cache_policies.py +11 -11
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/__init__.py +3 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/base.py +36 -37
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/cloud.py +26 -19
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/collections.py +2 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/orchestration.py +342 -273
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/schemas/__init__.py +24 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/schemas/actions.py +123 -116
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/schemas/objects.py +110 -81
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/schemas/responses.py +18 -18
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/schemas/schedules.py +136 -93
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/subscriptions.py +28 -14
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/utilities.py +32 -36
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/asyncio.py +6 -9
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/sync.py +35 -5
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/context.py +39 -31
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/flow_runs.py +3 -5
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/docker/__init__.py +1 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/schemas/events.py +25 -20
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/utilities.py +1 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/filesystems.py +3 -3
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/flow_engine.py +61 -21
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/flow_runs.py +3 -3
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/flows.py +214 -170
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/configuration.py +1 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/highlighters.py +1 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/loggers.py +30 -20
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/main.py +17 -24
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runner/runner.py +43 -21
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runner/server.py +30 -32
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runner/submit.py +3 -6
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runner/utils.py +6 -6
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runtime/flow_run.py +7 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/constants.py +2 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/legacy.py +1 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/events.py +10 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/task_engine.py +72 -19
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/task_runners.py +2 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/tasks.py +46 -33
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/telemetry/bootstrap.py +15 -2
- prefect-client-3.1.6/src/prefect/telemetry/run_telemetry.py +107 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/transactions.py +14 -14
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/types/__init__.py +1 -4
- prefect-client-3.1.6/src/prefect/utilities/_engine.py +96 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/annotations.py +25 -18
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/asyncutils.py +126 -140
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/callables.py +87 -78
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/collections.py +278 -117
- prefect-client-3.1.6/src/prefect/utilities/compat.py +23 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/context.py +6 -5
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/dispatch.py +23 -12
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/dockerutils.py +33 -32
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/engine.py +126 -239
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/filesystem.py +18 -15
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/hashing.py +10 -11
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/importtools.py +40 -27
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/math.py +9 -5
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/names.py +3 -3
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/processutils.py +121 -57
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/pydantic.py +41 -36
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/render_swagger.py +22 -12
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/schema_tools/__init__.py +2 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/schema_tools/hydration.py +50 -43
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/schema_tools/validation.py +52 -42
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/services.py +13 -12
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/templating.py +45 -45
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/text.py +2 -1
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/timeout.py +4 -4
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/urls.py +9 -4
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/visualization.py +46 -24
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/variables.py +9 -8
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/workers/base.py +15 -8
- {prefect-client-3.1.5 → prefect-client-3.1.6/src/prefect_client.egg-info}/PKG-INFO +4 -2
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect_client.egg-info/SOURCES.txt +2 -0
- prefect-client-3.1.5/src/prefect/utilities/compat.py +0 -31
- {prefect-client-3.1.5 → prefect-client-3.1.6}/LICENSE +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/requirements-client.txt +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/requirements-dev.txt +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/requirements.txt +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/setup.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/.prefectignore +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/_logging.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/compatibility/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/compatibility/async_dispatch.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/compatibility/deprecated.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/inspection.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/primitives.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/concurrency/services.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/integrations.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pydantic/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pydantic/annotations/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pydantic/annotations/pendulum.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pydantic/schemas.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pydantic/v2_validated_func.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/pytz.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/retries.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/schemas/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/schemas/fields.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/_internal/schemas/serializers.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/agent.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/artifacts.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/fields.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/notifications.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/redis.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/system.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/blocks/webhook.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/constants.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/schemas/filters.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/schemas/sorting.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/types/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/client/types/flexible_schedule_list.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/context.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/events.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/services.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/v1/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/v1/asyncio.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/v1/context.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/v1/events.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/v1/services.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/concurrency/v1/sync.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/base.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/deployments.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/runner.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/schedules.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/steps/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/steps/core.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/steps/pull.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/deployments/steps/utility.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/docker/docker_image.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/engine.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/actions.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/cli/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/cli/automations.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/clients.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/filters.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/related.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/schemas/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/schemas/automations.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/schemas/deployment_triggers.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/schemas/labelling.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/events/worker.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/exceptions.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/futures.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/infrastructure/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/infrastructure/base.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/infrastructure/provisioners/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/infrastructure/provisioners/cloud_run.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/infrastructure/provisioners/container_instance.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/infrastructure/provisioners/ecs.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/infrastructure/provisioners/modal.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/input/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/input/actions.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/input/run_input.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/locking/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/locking/filesystem.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/locking/memory.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/locking/protocol.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/filters.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/formatters.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/handlers.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/logging/logging.yml +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/plugins.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/py.typed +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/records/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/records/base.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/records/filesystem.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/records/memory.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/records/result_store.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/results.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runner/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runner/storage.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runtime/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runtime/deployment.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/runtime/task_run.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/serializers.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/server/api/collections_data/views/aggregate-worker-metadata.json +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/server/api/static/prefect-logo-mark-gradient.png +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/base.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/context.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/api.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/cli.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/client.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/cloud.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/deployments.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/experiments.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/flows.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/internal.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/logging.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/results.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/root.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/runner.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/api.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/database.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/deployments.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/ephemeral.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/flow_run_graph.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/root.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/services.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/tasks.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/server/ui.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/tasks.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/testing.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/models/worker.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/profiles.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/profiles.toml +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/settings/sources.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/states.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/task_runs.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/task_worker.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/telemetry/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/telemetry/instrumentation.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/telemetry/logging.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/telemetry/processors.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/types/entrypoint.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/utilities/slugify.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/workers/__init__.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/workers/block.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/workers/cloud.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/workers/process.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/workers/server.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect/workers/utilities.py +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect_client.egg-info/dependency_links.txt +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect_client.egg-info/requires.txt +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/src/prefect_client.egg-info/top_level.txt +0 -0
- {prefect-client-3.1.5 → prefect-client-3.1.6}/versioneer.py +0 -0
@@ -25,9 +25,9 @@ include src/prefect/server/api/collections_data/views/*.json
|
|
25
25
|
|
26
26
|
# Migrations
|
27
27
|
include src/prefect/server/database/alembic.ini
|
28
|
-
include src/prefect/server/database/
|
29
|
-
include src/prefect/server/database/
|
30
|
-
include src/prefect/server/database/
|
28
|
+
include src/prefect/server/database/_migrations/*
|
29
|
+
include src/prefect/server/database/_migrations/versions/*
|
30
|
+
include src/prefect/server/database/_migrations/versions/*/*
|
31
31
|
|
32
32
|
# SQL templates
|
33
33
|
graft src/prefect/server/database/sql
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: prefect-client
|
3
|
-
Version: 3.1.
|
3
|
+
Version: 3.1.6
|
4
4
|
Summary: Workflow orchestration and management.
|
5
5
|
Home-page: https://www.prefect.io
|
6
6
|
Author: Prefect Technologies, Inc.
|
@@ -126,7 +126,9 @@ Start with our [friendly tutorial](https://docs.prefect.io/tutorials) or explore
|
|
126
126
|
|
127
127
|
## Join the community
|
128
128
|
|
129
|
-
Prefect is made possible by the fastest growing community of thousands of friendly data engineers. Join us in building a new kind of workflow system.
|
129
|
+
Prefect is made possible by the fastest growing community of thousands of friendly data engineers. Join us in building a new kind of workflow system.
|
130
|
+
The [Prefect Slack community](https://prefect.io/slack) is a fantastic place to learn more about Prefect, ask questions, or get help with workflow design.
|
131
|
+
All community forums, including code contributions, issue discussions, and Slack messages are subject to our [Code of Conduct](https://github.com/PrefectHQ/prefect/blob/main/CODE_OF_CONDUCT.md).
|
130
132
|
|
131
133
|
## Contribute
|
132
134
|
|
@@ -98,7 +98,9 @@ Start with our [friendly tutorial](https://docs.prefect.io/tutorials) or explore
|
|
98
98
|
|
99
99
|
## Join the community
|
100
100
|
|
101
|
-
Prefect is made possible by the fastest growing community of thousands of friendly data engineers. Join us in building a new kind of workflow system.
|
101
|
+
Prefect is made possible by the fastest growing community of thousands of friendly data engineers. Join us in building a new kind of workflow system.
|
102
|
+
The [Prefect Slack community](https://prefect.io/slack) is a fantastic place to learn more about Prefect, ask questions, or get help with workflow design.
|
103
|
+
All community forums, including code contributions, issue discussions, and Slack messages are subject to our [Code of Conduct](https://github.com/PrefectHQ/prefect/blob/main/CODE_OF_CONDUCT.md).
|
102
104
|
|
103
105
|
## Contribute
|
104
106
|
|
@@ -38,6 +38,7 @@ if TYPE_CHECKING:
|
|
38
38
|
Transaction,
|
39
39
|
unmapped,
|
40
40
|
serve,
|
41
|
+
aserve,
|
41
42
|
deploy,
|
42
43
|
pause_flow_run,
|
43
44
|
resume_flow_run,
|
@@ -66,6 +67,7 @@ _public_api: dict[str, tuple[str, str]] = {
|
|
66
67
|
"Transaction": (__spec__.parent, ".main"),
|
67
68
|
"unmapped": (__spec__.parent, ".main"),
|
68
69
|
"serve": (__spec__.parent, ".main"),
|
70
|
+
"aserve": (__spec__.parent, ".main"),
|
69
71
|
"deploy": (__spec__.parent, ".main"),
|
70
72
|
"pause_flow_run": (__spec__.parent, ".main"),
|
71
73
|
"resume_flow_run": (__spec__.parent, ".main"),
|
@@ -86,6 +88,7 @@ __all__ = [
|
|
86
88
|
"Transaction",
|
87
89
|
"unmapped",
|
88
90
|
"serve",
|
91
|
+
"aserve",
|
89
92
|
"deploy",
|
90
93
|
"pause_flow_run",
|
91
94
|
"resume_flow_run",
|
@@ -6,51 +6,48 @@ import abc
|
|
6
6
|
import asyncio
|
7
7
|
import concurrent.futures
|
8
8
|
import contextlib
|
9
|
-
from
|
10
|
-
|
11
|
-
|
12
|
-
ContextManager,
|
13
|
-
Iterable,
|
14
|
-
Optional,
|
15
|
-
TypeVar,
|
16
|
-
Union,
|
17
|
-
)
|
9
|
+
from collections.abc import Awaitable, Iterable
|
10
|
+
from contextlib import AbstractContextManager
|
11
|
+
from typing import Any, Callable, Optional, Union, cast
|
18
12
|
|
19
|
-
from typing_extensions import ParamSpec
|
13
|
+
from typing_extensions import ParamSpec, TypeAlias, TypeVar
|
20
14
|
|
21
15
|
from prefect._internal.concurrency.threads import (
|
22
16
|
WorkerThread,
|
23
17
|
get_global_loop,
|
24
18
|
in_global_loop,
|
25
19
|
)
|
26
|
-
from prefect._internal.concurrency.waiters import
|
27
|
-
AsyncWaiter,
|
28
|
-
Call,
|
29
|
-
SyncWaiter,
|
30
|
-
)
|
20
|
+
from prefect._internal.concurrency.waiters import AsyncWaiter, Call, SyncWaiter
|
31
21
|
|
32
22
|
P = ParamSpec("P")
|
33
|
-
T = TypeVar("T")
|
34
|
-
Future = Union[concurrent.futures.Future, asyncio.Future]
|
23
|
+
T = TypeVar("T", infer_variance=True)
|
24
|
+
Future = Union[concurrent.futures.Future[T], asyncio.Future[T]]
|
25
|
+
|
26
|
+
_SyncOrAsyncCallable: TypeAlias = Callable[P, Union[T, Awaitable[T]]]
|
35
27
|
|
36
28
|
|
37
|
-
def create_call(
|
38
|
-
|
29
|
+
def create_call(
|
30
|
+
__fn: _SyncOrAsyncCallable[P, T], *args: P.args, **kwargs: P.kwargs
|
31
|
+
) -> Call[T]:
|
32
|
+
return Call[T].new(__fn, *args, **kwargs)
|
39
33
|
|
40
34
|
|
41
|
-
def
|
35
|
+
def cast_to_call(
|
36
|
+
call_like: Union["_SyncOrAsyncCallable[[], T]", Call[T]],
|
37
|
+
) -> Call[T]:
|
42
38
|
if isinstance(call_like, Call):
|
43
|
-
return call_like
|
39
|
+
return cast(Call[T], call_like)
|
44
40
|
else:
|
45
41
|
return create_call(call_like)
|
46
42
|
|
47
43
|
|
48
44
|
class _base(abc.ABC):
|
49
|
-
@
|
45
|
+
@staticmethod
|
46
|
+
@abc.abstractmethod
|
50
47
|
def wait_for_call_in_loop_thread(
|
51
|
-
__call: Union[
|
48
|
+
__call: Union["_SyncOrAsyncCallable[[], Any]", Call[T]],
|
52
49
|
timeout: Optional[float] = None,
|
53
|
-
done_callbacks: Optional[Iterable[Call]] = None,
|
50
|
+
done_callbacks: Optional[Iterable[Call[Any]]] = None,
|
54
51
|
) -> T:
|
55
52
|
"""
|
56
53
|
Schedule a function in the global worker thread and wait for completion.
|
@@ -59,11 +56,12 @@ class _base(abc.ABC):
|
|
59
56
|
"""
|
60
57
|
raise NotImplementedError()
|
61
58
|
|
62
|
-
@
|
59
|
+
@staticmethod
|
60
|
+
@abc.abstractmethod
|
63
61
|
def wait_for_call_in_new_thread(
|
64
|
-
__call: Union[
|
62
|
+
__call: Union["_SyncOrAsyncCallable[[], T]", Call[T]],
|
65
63
|
timeout: Optional[float] = None,
|
66
|
-
done_callbacks: Optional[Iterable[Call]] = None,
|
64
|
+
done_callbacks: Optional[Iterable[Call[Any]]] = None,
|
67
65
|
) -> T:
|
68
66
|
"""
|
69
67
|
Schedule a function in a new worker thread.
|
@@ -74,14 +72,15 @@ class _base(abc.ABC):
|
|
74
72
|
|
75
73
|
@staticmethod
|
76
74
|
def call_soon_in_new_thread(
|
77
|
-
__call: Union[
|
75
|
+
__call: Union["_SyncOrAsyncCallable[[], T]", Call[T]],
|
76
|
+
timeout: Optional[float] = None,
|
78
77
|
) -> Call[T]:
|
79
78
|
"""
|
80
79
|
Schedule a call for execution in a new worker thread.
|
81
80
|
|
82
81
|
Returns the submitted call.
|
83
82
|
"""
|
84
|
-
call =
|
83
|
+
call = cast_to_call(__call)
|
85
84
|
runner = WorkerThread(run_once=True)
|
86
85
|
call.set_timeout(timeout)
|
87
86
|
runner.submit(call)
|
@@ -89,7 +88,7 @@ class _base(abc.ABC):
|
|
89
88
|
|
90
89
|
@staticmethod
|
91
90
|
def call_soon_in_loop_thread(
|
92
|
-
__call: Union[
|
91
|
+
__call: Union["_SyncOrAsyncCallable[[], T]", Call[T]],
|
93
92
|
timeout: Optional[float] = None,
|
94
93
|
) -> Call[T]:
|
95
94
|
"""
|
@@ -97,7 +96,7 @@ class _base(abc.ABC):
|
|
97
96
|
|
98
97
|
Returns the submitted call.
|
99
98
|
"""
|
100
|
-
call =
|
99
|
+
call = cast_to_call(__call)
|
101
100
|
runner = get_global_loop()
|
102
101
|
call.set_timeout(timeout)
|
103
102
|
runner.submit(call)
|
@@ -116,7 +115,7 @@ class _base(abc.ABC):
|
|
116
115
|
|
117
116
|
@staticmethod
|
118
117
|
def call_in_loop_thread(
|
119
|
-
__call: Union[Callable[[], Awaitable[T]], Call[
|
118
|
+
__call: Union[Callable[[], Awaitable[T]], Call[T]],
|
120
119
|
timeout: Optional[float] = None,
|
121
120
|
) -> T:
|
122
121
|
"""
|
@@ -130,12 +129,12 @@ class _base(abc.ABC):
|
|
130
129
|
class from_async(_base):
|
131
130
|
@staticmethod
|
132
131
|
async def wait_for_call_in_loop_thread(
|
133
|
-
__call: Union[Callable[[], Awaitable[T]], Call[
|
132
|
+
__call: Union[Callable[[], Awaitable[T]], Call[T]],
|
134
133
|
timeout: Optional[float] = None,
|
135
|
-
done_callbacks: Optional[Iterable[Call]] = None,
|
136
|
-
contexts: Optional[Iterable[
|
137
|
-
) ->
|
138
|
-
call =
|
134
|
+
done_callbacks: Optional[Iterable[Call[Any]]] = None,
|
135
|
+
contexts: Optional[Iterable[AbstractContextManager[Any]]] = None,
|
136
|
+
) -> T:
|
137
|
+
call = cast_to_call(__call)
|
139
138
|
waiter = AsyncWaiter(call)
|
140
139
|
for callback in done_callbacks or []:
|
141
140
|
waiter.add_done_callback(callback)
|
@@ -150,9 +149,9 @@ class from_async(_base):
|
|
150
149
|
async def wait_for_call_in_new_thread(
|
151
150
|
__call: Union[Callable[[], T], Call[T]],
|
152
151
|
timeout: Optional[float] = None,
|
153
|
-
done_callbacks: Optional[Iterable[Call]] = None,
|
152
|
+
done_callbacks: Optional[Iterable[Call[Any]]] = None,
|
154
153
|
) -> T:
|
155
|
-
call =
|
154
|
+
call = cast_to_call(__call)
|
156
155
|
waiter = AsyncWaiter(call=call)
|
157
156
|
for callback in done_callbacks or []:
|
158
157
|
waiter.add_done_callback(callback)
|
@@ -169,7 +168,7 @@ class from_async(_base):
|
|
169
168
|
|
170
169
|
@staticmethod
|
171
170
|
def call_in_loop_thread(
|
172
|
-
__call: Union[Callable[[], Awaitable[T]], Call[
|
171
|
+
__call: Union[Callable[[], Awaitable[T]], Call[T]],
|
173
172
|
timeout: Optional[float] = None,
|
174
173
|
) -> Awaitable[T]:
|
175
174
|
call = _base.call_soon_in_loop_thread(__call, timeout=timeout)
|
@@ -181,13 +180,13 @@ class from_sync(_base):
|
|
181
180
|
def wait_for_call_in_loop_thread(
|
182
181
|
__call: Union[
|
183
182
|
Callable[[], Awaitable[T]],
|
184
|
-
|
183
|
+
Call[T],
|
185
184
|
],
|
186
185
|
timeout: Optional[float] = None,
|
187
|
-
done_callbacks: Optional[Iterable[Call]] = None,
|
188
|
-
contexts: Optional[Iterable[
|
189
|
-
) ->
|
190
|
-
call =
|
186
|
+
done_callbacks: Optional[Iterable[Call[T]]] = None,
|
187
|
+
contexts: Optional[Iterable[AbstractContextManager[Any]]] = None,
|
188
|
+
) -> T:
|
189
|
+
call = cast_to_call(__call)
|
191
190
|
waiter = SyncWaiter(call)
|
192
191
|
_base.call_soon_in_loop_thread(call, timeout=timeout)
|
193
192
|
for callback in done_callbacks or []:
|
@@ -202,9 +201,9 @@ class from_sync(_base):
|
|
202
201
|
def wait_for_call_in_new_thread(
|
203
202
|
__call: Union[Callable[[], T], Call[T]],
|
204
203
|
timeout: Optional[float] = None,
|
205
|
-
done_callbacks: Optional[Iterable[Call]] = None,
|
206
|
-
) ->
|
207
|
-
call =
|
204
|
+
done_callbacks: Optional[Iterable[Call[T]]] = None,
|
205
|
+
) -> T:
|
206
|
+
call = cast_to_call(__call)
|
208
207
|
waiter = SyncWaiter(call=call)
|
209
208
|
for callback in done_callbacks or []:
|
210
209
|
waiter.add_done_callback(callback)
|
@@ -214,20 +213,21 @@ class from_sync(_base):
|
|
214
213
|
|
215
214
|
@staticmethod
|
216
215
|
def call_in_new_thread(
|
217
|
-
__call: Union[
|
216
|
+
__call: Union["_SyncOrAsyncCallable[[], T]", Call[T]],
|
217
|
+
timeout: Optional[float] = None,
|
218
218
|
) -> T:
|
219
219
|
call = _base.call_soon_in_new_thread(__call, timeout=timeout)
|
220
220
|
return call.result()
|
221
221
|
|
222
222
|
@staticmethod
|
223
223
|
def call_in_loop_thread(
|
224
|
-
__call: Union[
|
224
|
+
__call: Union["_SyncOrAsyncCallable[[], T]", Call[T]],
|
225
225
|
timeout: Optional[float] = None,
|
226
|
-
) -> T:
|
226
|
+
) -> Union[Awaitable[T], T]:
|
227
227
|
if in_global_loop():
|
228
228
|
# Avoid deadlock where the call is submitted to the loop then the loop is
|
229
229
|
# blocked waiting for the call
|
230
|
-
call =
|
230
|
+
call = cast_to_call(__call)
|
231
231
|
return call()
|
232
232
|
|
233
233
|
call = _base.call_soon_in_loop_thread(__call, timeout=timeout)
|
@@ -12,18 +12,20 @@ import dataclasses
|
|
12
12
|
import inspect
|
13
13
|
import threading
|
14
14
|
import weakref
|
15
|
+
from collections.abc import Awaitable, Generator
|
15
16
|
from concurrent.futures._base import (
|
16
17
|
CANCELLED,
|
17
18
|
CANCELLED_AND_NOTIFIED,
|
18
19
|
FINISHED,
|
19
20
|
RUNNING,
|
20
21
|
)
|
21
|
-
from typing import
|
22
|
+
from typing import TYPE_CHECKING, Any, Callable, Generic, Optional, Union
|
22
23
|
|
23
|
-
from typing_extensions import ParamSpec
|
24
|
+
from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, TypeVarTuple
|
24
25
|
|
25
26
|
from prefect._internal.concurrency import logger
|
26
27
|
from prefect._internal.concurrency.cancellation import (
|
28
|
+
AsyncCancelScope,
|
27
29
|
CancelledError,
|
28
30
|
cancel_async_at,
|
29
31
|
cancel_sync_at,
|
@@ -31,9 +33,13 @@ from prefect._internal.concurrency.cancellation import (
|
|
31
33
|
)
|
32
34
|
from prefect._internal.concurrency.event_loop import get_running_loop
|
33
35
|
|
34
|
-
T = TypeVar("T")
|
36
|
+
T = TypeVar("T", infer_variance=True)
|
37
|
+
Ts = TypeVarTuple("Ts")
|
35
38
|
P = ParamSpec("P")
|
36
39
|
|
40
|
+
_SyncOrAsyncCallable: TypeAlias = Callable[P, Union[T, Awaitable[T]]]
|
41
|
+
|
42
|
+
|
37
43
|
# Tracks the current call being executed. Note that storing the `Call`
|
38
44
|
# object for an async call directly in the contextvar appears to create a
|
39
45
|
# memory leak, despite the fact that we `reset` when leaving the context
|
@@ -41,16 +47,16 @@ P = ParamSpec("P")
|
|
41
47
|
# we already have strong references to the `Call` objects in other places
|
42
48
|
# and b) this is used for performance optimizations where we have fallback
|
43
49
|
# behavior if this weakref is garbage collected. A fix for issue #10952.
|
44
|
-
current_call: contextvars.ContextVar["weakref.ref[Call]"] = ( # novm
|
50
|
+
current_call: contextvars.ContextVar["weakref.ref[Call[Any]]"] = ( # novm
|
45
51
|
contextvars.ContextVar("current_call")
|
46
52
|
)
|
47
53
|
|
48
54
|
# Create a strong reference to tasks to prevent destruction during execution errors
|
49
|
-
_ASYNC_TASK_REFS = set()
|
55
|
+
_ASYNC_TASK_REFS: set[asyncio.Task[None]] = set()
|
50
56
|
|
51
57
|
|
52
58
|
@contextlib.contextmanager
|
53
|
-
def set_current_call(call: "Call"):
|
59
|
+
def set_current_call(call: "Call[Any]") -> Generator[None, Any, None]:
|
54
60
|
token = current_call.set(weakref.ref(call))
|
55
61
|
try:
|
56
62
|
yield
|
@@ -58,7 +64,7 @@ def set_current_call(call: "Call"):
|
|
58
64
|
current_call.reset(token)
|
59
65
|
|
60
66
|
|
61
|
-
class Future(concurrent.futures.Future):
|
67
|
+
class Future(concurrent.futures.Future[T]):
|
62
68
|
"""
|
63
69
|
Extension of `concurrent.futures.Future` with support for cancellation of running
|
64
70
|
futures.
|
@@ -70,7 +76,7 @@ class Future(concurrent.futures.Future):
|
|
70
76
|
super().__init__()
|
71
77
|
self._cancel_scope = None
|
72
78
|
self._deadline = None
|
73
|
-
self._cancel_callbacks = []
|
79
|
+
self._cancel_callbacks: list[Callable[[], None]] = []
|
74
80
|
self._name = name
|
75
81
|
self._timed_out = False
|
76
82
|
|
@@ -79,7 +85,7 @@ class Future(concurrent.futures.Future):
|
|
79
85
|
return super().set_running_or_notify_cancel()
|
80
86
|
|
81
87
|
@contextlib.contextmanager
|
82
|
-
def enforce_async_deadline(self):
|
88
|
+
def enforce_async_deadline(self) -> Generator[AsyncCancelScope]:
|
83
89
|
with cancel_async_at(self._deadline, name=self._name) as self._cancel_scope:
|
84
90
|
for callback in self._cancel_callbacks:
|
85
91
|
self._cancel_scope.add_cancel_callback(callback)
|
@@ -92,7 +98,7 @@ class Future(concurrent.futures.Future):
|
|
92
98
|
self._cancel_scope.add_cancel_callback(callback)
|
93
99
|
yield self._cancel_scope
|
94
100
|
|
95
|
-
def add_cancel_callback(self, callback: Callable[[],
|
101
|
+
def add_cancel_callback(self, callback: Callable[[], Any]) -> None:
|
96
102
|
"""
|
97
103
|
Add a callback to be enforced on cancellation.
|
98
104
|
|
@@ -113,7 +119,7 @@ class Future(concurrent.futures.Future):
|
|
113
119
|
with self._condition:
|
114
120
|
return self._timed_out
|
115
121
|
|
116
|
-
def cancel(self):
|
122
|
+
def cancel(self) -> bool:
|
117
123
|
"""Cancel the future if possible.
|
118
124
|
|
119
125
|
Returns True if the future was cancelled, False otherwise. A future cannot be
|
@@ -147,7 +153,12 @@ class Future(concurrent.futures.Future):
|
|
147
153
|
self._invoke_callbacks()
|
148
154
|
return True
|
149
155
|
|
150
|
-
|
156
|
+
if TYPE_CHECKING:
|
157
|
+
|
158
|
+
def __get_result(self) -> T:
|
159
|
+
...
|
160
|
+
|
161
|
+
def result(self, timeout: Optional[float] = None) -> T:
|
151
162
|
"""Return the result of the call that the future represents.
|
152
163
|
|
153
164
|
Args:
|
@@ -186,7 +197,9 @@ class Future(concurrent.futures.Future):
|
|
186
197
|
# Break a reference cycle with the exception in self._exception
|
187
198
|
self = None
|
188
199
|
|
189
|
-
|
200
|
+
_done_callbacks: list[Callable[[Self], object]]
|
201
|
+
|
202
|
+
def _invoke_callbacks(self) -> None:
|
190
203
|
"""
|
191
204
|
Invoke our done callbacks and clean up cancel scopes and cancel
|
192
205
|
callbacks. Fixes a memory leak that hung on to Call objects,
|
@@ -206,7 +219,7 @@ class Future(concurrent.futures.Future):
|
|
206
219
|
|
207
220
|
self._cancel_callbacks = []
|
208
221
|
if self._cancel_scope:
|
209
|
-
self._cancel_scope
|
222
|
+
setattr(self._cancel_scope, "_callbacks", [])
|
210
223
|
self._cancel_scope = None
|
211
224
|
|
212
225
|
|
@@ -216,16 +229,21 @@ class Call(Generic[T]):
|
|
216
229
|
A deferred function call.
|
217
230
|
"""
|
218
231
|
|
219
|
-
future: Future
|
220
|
-
fn:
|
221
|
-
args:
|
222
|
-
kwargs:
|
232
|
+
future: Future[T]
|
233
|
+
fn: "_SyncOrAsyncCallable[..., T]"
|
234
|
+
args: tuple[Any, ...]
|
235
|
+
kwargs: dict[str, Any]
|
223
236
|
context: contextvars.Context
|
224
|
-
timeout: float
|
237
|
+
timeout: Optional[float]
|
225
238
|
runner: Optional["Portal"] = None
|
226
239
|
|
227
240
|
@classmethod
|
228
|
-
def new(
|
241
|
+
def new(
|
242
|
+
cls,
|
243
|
+
__fn: _SyncOrAsyncCallable[P, T],
|
244
|
+
*args: P.args,
|
245
|
+
**kwargs: P.kwargs,
|
246
|
+
) -> Self:
|
229
247
|
return cls(
|
230
248
|
future=Future(name=getattr(__fn, "__name__", str(__fn))),
|
231
249
|
fn=__fn,
|
@@ -255,7 +273,7 @@ class Call(Generic[T]):
|
|
255
273
|
|
256
274
|
self.runner = portal
|
257
275
|
|
258
|
-
def run(self) -> Optional[Awaitable[
|
276
|
+
def run(self) -> Optional[Awaitable[None]]:
|
259
277
|
"""
|
260
278
|
Execute the call and place the result on the future.
|
261
279
|
|
@@ -337,7 +355,7 @@ class Call(Generic[T]):
|
|
337
355
|
def cancel(self) -> bool:
|
338
356
|
return self.future.cancel()
|
339
357
|
|
340
|
-
def _run_sync(self):
|
358
|
+
def _run_sync(self) -> Optional[Awaitable[T]]:
|
341
359
|
cancel_scope = None
|
342
360
|
try:
|
343
361
|
with set_current_call(self):
|
@@ -348,8 +366,8 @@ class Call(Generic[T]):
|
|
348
366
|
# Forget this call's arguments in order to free up any memory
|
349
367
|
# that may be referenced by them; after a call has happened,
|
350
368
|
# there's no need to keep a reference to them
|
351
|
-
|
352
|
-
|
369
|
+
with contextlib.suppress(AttributeError):
|
370
|
+
del self.args, self.kwargs
|
353
371
|
|
354
372
|
# Return the coroutine for async execution
|
355
373
|
if inspect.isawaitable(result):
|
@@ -357,8 +375,10 @@ class Call(Generic[T]):
|
|
357
375
|
|
358
376
|
except CancelledError:
|
359
377
|
# Report cancellation
|
378
|
+
if TYPE_CHECKING:
|
379
|
+
assert cancel_scope is not None
|
360
380
|
if cancel_scope.timedout():
|
361
|
-
self.future
|
381
|
+
setattr(self.future, "_timed_out", True)
|
362
382
|
self.future.cancel()
|
363
383
|
elif cancel_scope.cancelled():
|
364
384
|
self.future.cancel()
|
@@ -374,8 +394,8 @@ class Call(Generic[T]):
|
|
374
394
|
self.future.set_result(result) # noqa: F821
|
375
395
|
logger.debug("Finished call %r", self) # noqa: F821
|
376
396
|
|
377
|
-
async def _run_async(self, coro):
|
378
|
-
cancel_scope = None
|
397
|
+
async def _run_async(self, coro: Awaitable[T]) -> None:
|
398
|
+
cancel_scope = result = None
|
379
399
|
try:
|
380
400
|
with set_current_call(self):
|
381
401
|
with self.future.enforce_async_deadline() as cancel_scope:
|
@@ -385,12 +405,14 @@ class Call(Generic[T]):
|
|
385
405
|
# Forget this call's arguments in order to free up any memory
|
386
406
|
# that may be referenced by them; after a call has happened,
|
387
407
|
# there's no need to keep a reference to them
|
388
|
-
|
389
|
-
|
408
|
+
with contextlib.suppress(AttributeError):
|
409
|
+
del self.args, self.kwargs
|
390
410
|
except CancelledError:
|
391
411
|
# Report cancellation
|
412
|
+
if TYPE_CHECKING:
|
413
|
+
assert cancel_scope is not None
|
392
414
|
if cancel_scope.timedout():
|
393
|
-
self.future
|
415
|
+
setattr(self.future, "_timed_out", True)
|
394
416
|
self.future.cancel()
|
395
417
|
elif cancel_scope.cancelled():
|
396
418
|
self.future.cancel()
|
@@ -403,10 +425,11 @@ class Call(Generic[T]):
|
|
403
425
|
# Prevent reference cycle in `exc`
|
404
426
|
del self
|
405
427
|
else:
|
428
|
+
# F821 ignored because Ruff gets confused about the del self above.
|
406
429
|
self.future.set_result(result) # noqa: F821
|
407
430
|
logger.debug("Finished async call %r", self) # noqa: F821
|
408
431
|
|
409
|
-
def __call__(self) -> T:
|
432
|
+
def __call__(self) -> Union[T, Awaitable[T]]:
|
410
433
|
"""
|
411
434
|
Execute the call and return its result.
|
412
435
|
|
@@ -417,7 +440,7 @@ class Call(Generic[T]):
|
|
417
440
|
# Return an awaitable if in an async context
|
418
441
|
if coro is not None:
|
419
442
|
|
420
|
-
async def run_and_return_result():
|
443
|
+
async def run_and_return_result() -> T:
|
421
444
|
await coro
|
422
445
|
return self.result()
|
423
446
|
|
@@ -428,8 +451,9 @@ class Call(Generic[T]):
|
|
428
451
|
def __repr__(self) -> str:
|
429
452
|
name = getattr(self.fn, "__name__", str(self.fn))
|
430
453
|
|
431
|
-
|
432
|
-
|
454
|
+
try:
|
455
|
+
args, kwargs = self.args, self.kwargs
|
456
|
+
except AttributeError:
|
433
457
|
call_args = "<dropped>"
|
434
458
|
else:
|
435
459
|
call_args = ", ".join(
|
@@ -450,7 +474,7 @@ class Portal(abc.ABC):
|
|
450
474
|
"""
|
451
475
|
|
452
476
|
@abc.abstractmethod
|
453
|
-
def submit(self, call: "Call") -> "Call":
|
477
|
+
def submit(self, call: "Call[T]") -> "Call[T]":
|
454
478
|
"""
|
455
479
|
Submit a call to execute elsewhere.
|
456
480
|
|