Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

godale

Debauchery tools for concurrent task execution.

pipeline status coverage report

Here you find wrappers around some concurrent.futures, multiprocessing and billiard functions to facilitate switching between parallelization implementations:

  • concurrent.futures multithreading: Python 3 standard tool for multithreading
  • concurrent.futures multiprocessing: Python 3 standard tool for multiprocessing
  • multiprocessing multiprocessing: Python 3 standard tool for multiprocessing
  • billiard multiprocessing: Multiprocessing for celery workers.

All four currently implemented wrappers handle parallel execution of the tasks and yield result (FinishedTask) objects having result() and exception() methods. This enables catching of exceptions without cancelling remaining tasks.

Usage:

from godale import Executor

# the first function argument will be replaced by items from the "items" argument below
# subsequent arguments and keyword arguments can be passed on using "fargs" and "fkwargs"
def _worker_function(a, b, some_kwarg=None):
    return a * b


# multiprocessing the Python 3 way
executor = Executor(executor="concurrent_processes")
for task in executor.as_completed(
    func=_worker_function,  # function to be executed
    iterable=range(100),  # items to be parallelized
    fargs=(10, ),  # other function arguments
    fkwargs={"a_kwarg"=True}  # function keyword arguments
):
    try:
        print(task.result())
    except ValueError:
        print("task failed")


# multithreading the Python 3 way
executor = Executor(executor="concurrent_threads")
for task in executor.as_completed(
    func=_worker_function,
    iterable=range(100),
    fargs=(10, )
):
    try:
        print(task.result())
    except ValueError:
        print("task failed")


# multiprocessing within a celery worker
executor = Executor(executor="billiard")
for task in executor.as_completed(
    func=_worker_function,
    iterable=range(100),
    fargs=(10, )
):
    try:
        print(task.result())
    except ValueError:
        print("task failed")


# using the multiprocessing standard module
executor = Executor(executor="multiprocessing")
for task in executor.as_completed(
    func=_worker_function,
    iterable=range(100),
    fargs=(10, )
):
    try:
        print(task.result())
    except ValueError:
        print("task failed")


# use different start_method than "fork"
# NOTE: with concurrent.futures and Python 3.6 and earlier, "start_method" other than
# "fork" will raise an RuntimeError
for task in executor.as_completed(
    func=_worker_function,
    iterable=range(100),
    fargs=(10, ),
    start_method="spawn"
):
    try:
        print(task.result())
    except ValueError:
        print("task failed")

Release files for godale 0.3

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

Source distribution (sdist)

Source distribution for godale 0.3
File Size Uploaded
godale-0.3.tar.gz 4.7 kB Details

Built distribution (wheel)

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

Total release size: 11.0 kB

Release files / godale-0.3.tar.gz

Download URL godale-0.3.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9bfd9d984348120f9ed8524731eb639b029d9f55001b1f882485fd7ebf33f3a3
BLAKE2b-256 checksum
How to use checksums
176171fadf752d03d001996c73a62af913e46719525be043241e752cb696106a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release files / godale-0.3-py3-none-any.whl

Download URL godale-0.3-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a9d3f2e237e8b3782d455e17cc79ead0cb11c4d522bdf6fb66f8edb210be6bf
BLAKE2b-256 checksum
How to use checksums
f0fae4d9566b6fb0aaf0f6d605c4498c9377097c48188286a2a2e48b1c703667
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

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