Skip to main content

Simple task manager to handle execution of tasks in AWS docker or any system. It use a handler that can be loaded dynamically.

Project description

Simple Task Manager (STMGR)

This is a simple task manager to start processes on AWS/Docker or other platforms. The app includes classes to manage tasks on AWS, but you can implement additional handlers dynamically.

You only need to create a class to handle the task that you want to start and register it in a database (DDBB). Below, I'll compare STMGR with Celery (since it's widely used) to explain the key differences and help you make an informed choice. Another good choice is Dramatiq. For a simple comparison between STMGR and Celery check

Requirements

  • Python 3.10 or newer
  • PostgreSQL
  • psycopg[binary]

Installation

This project can be installed using pip:

pip install simple-task-manager

Or it can be installed directly from git: pip install git+https://github.com/Fran-4c4/staskmgr

Upgrade from 1.5.x

  • Existing client code using TaskDB can remain synchronous.
  • The service runtime now uses an async SQLAlchemy layer internally.
  • Backward compatibility is preserved through compatibility modes:
    • LEGACY: old behavior only
    • AUTO: use safe mode when the upgraded schema is available
    • SAFE: require the upgraded schema and enable lease-based recovery
  • To upgrade an existing installation, apply config/ddbb_upgrade_1_6.sql before enabling SAFE mode.

See Upgrade guide.

Task log correlation

Version 1.6.1 adds best-effort task correlation metadata for external containers. TASK_ID remains the minimum identity needed to execute a concrete task; optional fields such as PARENT_REQUEST_ID, PROCESS_CHAIN_ID, TASK_TYPE, TASK_MANAGER, SERVICE_NAME and DEPLOYMENT_ENVIRONMENT are propagated when available.

Docker launches receive environment variables and labels. ECS launches receive container environment overrides and task tags. Missing optional metadata does not break legacy task definitions.

Usage and requirements

  • First you need to configure the minimum parameters in order to run tasks. See Configuration
  • Second you need a database to store configuration and task management. See table creation in folder config/ddbb_script.sql or Configuration scripts. Actually only PostgreSQL is supported.

More info in github GitHub.


Adding handlers

In order to manage other types you need to create a class and an entry in DDBB or in your appconfig.json in the section task_handlers. When the task is retrieved from DDBB it will look the handler. Below is an example of the Test task handler.

"task_handlers": {
    "TEST_MGR": {
      "config": {
        "task_handler": {
          "name": "TestTaskHandler",
          "path": "task_handlers",
          "class": "TestTaskHandler",
          "module": "test_task_handler",
          "launchType": "INTERNAL",
		      "task_next_status":"FINISHED"
        }
      }
    }
  }

Test in local

Install using pip in your project using the next command and changing x.x.x version.

pip install "path_to_dist/dist/Simple_Task_Manager-x.x.x-py3-none-any.whl" 

Sphinx documentation

  • There is a minimal documentation generated from source. See Documentation

Running as a Docker service

STMGR is normally deployed as a service inside Docker.

  1. Build an image based on Python 3.10 or newer.
  2. Install the package version you want to run.
  3. Mount the configuration and provide database credentials.
  4. Apply the SQL upgrade before enabling SAFE mode.

See Docker notes.

Docker handler modes

DockerTaskHandler now supports two modes:

  • DETACHED: default mode, intended for heavy containers. Launch and return immediately.
  • BLOCKING: wait for the container to finish. Intended for lightweight containers.
  • In DETACHED, STMGR can later reconcile the container state using external_ref when the upgraded schema is enabled.

See Docker handler guide.

License

licensed under Apache License 2.0

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

simple_task_manager-1.6.1.tar.gz (51.5 kB view details)

Uploaded Source

Built Distribution

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

simple_task_manager-1.6.1-py3-none-any.whl (56.4 kB view details)

Uploaded Python 3

File details

Details for the file simple_task_manager-1.6.1.tar.gz.

File metadata

  • Download URL: simple_task_manager-1.6.1.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for simple_task_manager-1.6.1.tar.gz
Algorithm Hash digest
SHA256 509644240880544938185252fbb164827aa6bc66bf46a55ca14da8e8e0cb493f
MD5 c794683cc1445350562c16c1f641182b
BLAKE2b-256 79ec173747b3d93aa79e997a1b0cb30c766a0ee31bf3de84959b19c6b84f5972

See more details on using hashes here.

File details

Details for the file simple_task_manager-1.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_task_manager-1.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2170614cbbd5e5ef986564c426fb46423344ece71b5e63d8c4eb6a8c188a1988
MD5 59808c676856729cb0f1ec63051e7180
BLAKE2b-256 73dc295bffd2d5f1621d8616cfa19dc01dd899e223e7e8226ac25d41a09fc1f2

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