Skip to main content

A simple threaded task launcher that emulates unix service-unit style behavior

Project description

PseudoService

A simple threaded task launcher that emulates unix service-unit style behavior.

Introduction

PseudoService is a simple scheduled threading task manager for Python applications. It provides a convenient way to manage tasks in a threaded environment.

Usage

To use PseudoService, follow these steps:

  1. Import the Launcher class from the pseudoservice module.
  2. Define your tasks as a dictionary where each key represents a task name and each value is a dictionary specifying the task details.
  3. Initialize an instance of Launcher with your tasks.
  4. Start the tasks using the start_tasks() method.

Example Usage

from pseudoservice import Launcher
import mytask_1
import mytask_2
import mytask_3

# Define tasks
tasks = {
    'My first task': {  # A task that will restart if the thread is closed.
        'task': mytask_1,
        'restart': True
    },
    'My second task': {  # A task with arguments that will run once and then close.
        'task': mytask_2,
        'args': [var_1, var_2, var_3]
    },
    'My third task': {  # A task with arguments and keyword arguments that will restart if the thread is closed.
        'task': mytask_3,
        'args': [var_1, var_2],
        'kwargs': {'varname_1': var_1, 'varname_2': var_2},
        'restart': True
    },
}

# Initialize and start tasks
task_launcher = Launcher(tasks)
task_launcher.start_tasks()

Launcher Class

Launcher(tasks: dict)

Initialize the Launcher class with a dictionary of tasks.

Methods

start_tasks(): Launches the threaded tasks.

Task Configuration

Each task is defined by a dictionary with the following keys:

  • task: Required. Specifies the task to be executed.

  • args: Optional. Arguments to be passed to the task function.

  • kwargs: Optional. Keyword arguments to be passed to the task function.

  • restart: Optional. Specifies whether the task should restart if the thread is closed.

  • delay: Optional. Specifies the delay (in seconds) between successive executions of the task. Notes

  • Tasks are executed in separate threads.

  • The Launcher class handles task scheduling and thread management.

Initialization

PseudoService can be installed from pip.

pip install pseudoservice

Credits

PseudoService was developed by Manbehindthemadness.

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

pseudoservice-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

pseudoservice-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file pseudoservice-0.1.0.tar.gz.

File metadata

  • Download URL: pseudoservice-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pseudoservice-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d253112dedf4110ba128df7014236fcc65c71e001efa53726e6a20e69b020470
MD5 f41fa579ee4b40a5223ff82e5bb4a5b5
BLAKE2b-256 bfb1613ab10839faead93ad508fbdaf055c61b84e048439743ae29a2a26ba287

See more details on using hashes here.

File details

Details for the file pseudoservice-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pseudoservice-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 521a8fd923e886e26a11721d315e49a1c206a56df63300f775221267f0f02ee3
MD5 acffaef25b90b63e7aa917f0d3980547
BLAKE2b-256 6d0e2addebdd20179591fa1897ad1b6d2fc8d7ab36dc02af5d22a832c4f6e671

See more details on using hashes here.

Supported by

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