Skip to main content

sametime

Bounded synchronous thread concurrency for independent I/O operations.

sametime provides structured thread management built directly on Python's standard library concurrent.futures. Requires Python 3.14+.

Highlights

  • Strict Resource Bounds: Controls both worker count (max_workers) and queued futures (max_pending), preventing memory ballooning on large/infinite input iterables.
  • Context-Managed Lifecycle: Automatic cancellation of pending tasks and graceful thread joins on context exit.
  • Ordered & Unordered Execution: Preserve input order or stream results as soon as they complete (ordered=False).
  • Flexible Failure Strategies: Choose between fail-fast behavior (thread_map, thread_iter) or indexed outcomes with error capture (thread_outcomes).
  • Consumer-Thread Callbacks: on_result callbacks execute safely on the caller's thread before results are yielded.

Installation

pip install sametime

For development:

git clone https://github.com/wispsy/sametime.git
cd sametime
uv sync

Quick Start

Basic Parallel Mapping

from sametime import thread_map

results = thread_map(len, ['hello', 'world', 'concurrency'], max_workers=3)
assert results == [5, 5, 11]

Streaming Results As They Complete

from sametime import thread_iter

with thread_iter(fetch, urls, max_workers=4, ordered=False) as stream:
    for item in stream:
        handle(item)

Tolerating Per-Item Errors with Outcome

from sametime import thread_outcomes

with thread_outcomes(int, ['10', 'invalid', '30'], max_pending=2) as results:
    for outcome in results:
        if outcome.ok:
            print(f"Item #{outcome.index} = {outcome.value}")
        else:
            print(f"Item #{outcome.index} error: {outcome.error}")

Documentation

See docs/api.md for full API details, threading guarantees, and design considerations.

Running Tests

python -m unittest discover -s tests -v

License

MIT

Metadata

Release files for sametime 0.1.0

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

Source distribution (sdist)

Source distribution for sametime 0.1.0
File Size Uploaded Provenance Actions
sametime-0.1.0.tar.gz 8.8 kB With provenance Details for sametime-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 14.4 kB

Release files / sametime-0.1.0.tar.gz

Download URL sametime-0.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c7b3c6d3460e3bb6ec8983a9cd97dd4e6eb7c0deeba8518524f93a370dd865c0
BLAKE2b-256 checksum
How to use checksums
89fb93011dbc82eafbbf7e3e8ede8ea88407f8e77450c7efc93871d0558585ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Release files / sametime-0.1.0-py3-none-any.whl

Download URL sametime-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
261b6ef5ac084e7001430ca5c0bb518f68e079d41f2eb40be98dfc259bb3db9c
BLAKE2b-256 checksum
How to use checksums
15cd0081e53aea43a42f94abe6fd26c93f68c1706369bad958c118ad293b9877
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

Security for sametime 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sametime-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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