Skip to main content

A Python library for managing and executing long-running tasks in batches with visual progress tracking

Project description

inch

Inch is a Python library specifically designed to manage and execute long-running tasks in batches using multithreading. It enhances the user experience by providing a visual progress display through the rich library. The name "Inch" reflects its core functionality, enabling tasks to "move along slowly and carefully," thus ensuring a systematic and controlled execution process.

DEMO

Online Demo

Features

  • Define concurrent tasks using an abstract base class.
  • Execute multiple tasks concurrently with adjustable worker threads.
  • Track and display task progress using the rich library.

Installation

Inch can be installed using pip:

pip install inch

Show demo:

python -m inch

Usage

Here's an example of how to use Inch to execute a simple task:

from inch import Inch, InchPoolExecutor
import random
from time import sleep

class TestTask(Inch):
    def __call__(self):
        while self.completed < self.total:
            self.completed += random.randint(1, 200)
            sleep(0.1)

class TestTaskNoProgress(Inch):

    def __call__(self):
        completed = 0
        while completed < 1200:
            completed += random.randint(1, 200)
            sleep(0.1)

with InchPoolExecutor() as executor:
    for i in range(20):
        if i % 5 == 0:
            executor.start_inch(TestTaskNoProgress(name=f"Task {i+1}"))
        else:
            executor.start_inch(TestTask(name=f"Task {i+1}", total=1000))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inch-0.2.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

inch-0.2.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file inch-0.2.0.tar.gz.

File metadata

  • Download URL: inch-0.2.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for inch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0d2aa9330094c89121ae043f2272f0b94963ee9b1e89bd7e8aef215e49d3c0d8
MD5 de627e840bdcb349e2b671e33bcc3d7d
BLAKE2b-256 e02921a1ca50d808efb69877414268bb92e6674718f822be49702498500141a7

See more details on using hashes here.

File details

Details for the file inch-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: inch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for inch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad01d5b6d9268c01b83039060aeaf0e79d6de16b51ad0d87a79c924695378b33
MD5 f21d0e9111a5efb6a78a56d1827450a1
BLAKE2b-256 780dce2dd8683e262781750e8fb6d661dc448a14f017afba3c9cf53c5c8385da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page