Skip to main content

Simple task management

Project description

https://badge.fury.io/py/taskin.png https://travis-ci.org/ionrock/taskin.png?branch=master

Taskin provides simple task management. Tasks are simple callables that will be executed using a pool of resources. The pool can be a process or thread pool in order to achieve the required concurrency. The suite of tasks is called a flow. A flow is defined by defining a list of functions to run.

Here is an example:

import subprocess

from pprint import pprint

from taskin import IfTask, MapTask, do_flow


def foo(data):
    return 1


def check(v):
    return v == 1


def bar(data):
    return 'bar'


def baz(data):
    return 'baz'


def finish(data):
    result = {}

    for i in data:
        zone, ips = i
        result[zone] = ips

    return result


def dig_it(zone):
    cmd = 'dig +short %s' % zone
    print('running: %s' % cmd.strip())

    ips = subprocess.check_output(cmd.split()).strip().split('\n')
    return (zone, ips)


myflow = [
    foo,
    IfTask(
        check,
        [bar],
        [baz]
    ),
    MapTask(dig_it, [
        'ionrock.org',
        'google.com',
        'yahoo.com',
    ]),
    finish,
]


def main():
    results = do_flow(myflow, {})
    pprint(results)
    print('Done')

if __name__ == '__main__':
    main()

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

taskin-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: taskin-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for taskin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1c865fbec4e9aa3a78b71e721aebb3093ab0967933159e3b57214d299df7c63a
MD5 45107ee2c8d1b9da829c194c6d27b146
BLAKE2b-256 760573960148c339579a37223423ad4d06b0de46e0ea93c32a4a440658e821e3

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