Skip to main content

p4async

An async extension to p4python (PyPI, GitHub), the Python client for the Perforce (P4) version control server. This package adds awaitable wrappers around p4python operations for asyncio-based applications.

Setup

Use your favorite package manager to install the module into your project

  • pip install p4async
  • uv add p4async

Usage

from p4async import P4Async

p4a = P4Async()
await p4a.aconnect()

All relevant Perforce commands have async counterparts prefixed with a. For example: aconnect(), arun(), arun_clients(), afetch_change(), etc.

Commands are executed with a lock on a worker thread. The way this is done can be customized via subclassing.

Note: Earlier versions of p4python (prior to 2025.2) did not release the Python GIL (global interpreter lock) during connect() calls, which made aconnect() blocking. This was fixed in p4python 2025.2. For optimal async performance, use p4python 2025.2 or later.

Subclassing

P4Async provides core async wrappers, while keeping a few hooks intentionally overridable for custom behavior.

  • Override execute(self, func, *args, **kwargs) to customize how synchronous work is scheduled (for example, custom executors or instrumentation).
  • Override sync_run(self, *args, **kwargs) to wrap the underlying synchronous run() call with extra behavior. This is the primary hook around command execution.
  • Extend simple_wrap_methods and run_wrap_methods in a subclass to add additional auto-generated async wrappers in the a<method> pattern.
from p4async import P4Async


class MyP4Async(P4Async):
    async def execute(self, func, *args, **kwargs):
        # Custom scheduling/telemetry hook
        return await super().execute(func, *args, **kwargs)

    def sync_run(self, *args, **kwargs):
        # Custom behavior around the underlying P4 run()
        return super().sync_run(*args, **kwargs)

    # Example: add async wrappers for extra methods
    simple_wrap_methods = P4Async.simple_wrap_methods | {"my_custom_sync_method"}

Development

  • Use uv for dependency management and virtual environments.
  • Format and lint with ruff:
    • uvx ruff check
    • uvx ruff format --check
    • uvx ruff format
  • Run type checking for the package:
    • uv run mypy src

License

MIT

Metadata

Release files for p4async 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for p4async 0.1.10
File Size Uploaded Provenance Actions
p4async-0.1.10.tar.gz 32.8 kB Without provenance Details for p4async-0.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for p4async 0.1.10
File Interpreter ABI Platform Actions
p4async-0.1.10-py3-none-any.whl Python 3 none any Details for p4async-0.1.10-py3-none-any.whl

Total release size: 38.1 kB

Release files / p4async-0.1.10.tar.gz

Download URL p4async-0.1.10.tar.gz
Size 32.8 kB
Tags Source
SHA-256 checksum
How to use checksums
06e3c82d016f5a00d1d5fc36b91f69321adebfbecffbb5e565538c5060899203
BLAKE2b-256 checksum
How to use checksums
ba713a8e65433ed3a7a56dc74e00c5099908a0f8306fb73307b2a7b75c4bc9cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / p4async-0.1.10-py3-none-any.whl

Download URL p4async-0.1.10-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1711972ed49068767c037def04d0c2a084ec94206251bad4824b240071285dd
BLAKE2b-256 checksum
How to use checksums
eed89556e5584a64ca5bd9c184dd4cc3b0bb918316be32ac330c35e8d374f7e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for p4async 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page