Skip to main content

Jobslib is a library for launching Python tasks in parallel environment. Our use-case is. We have two datacenters (in near future three datacenters), in each datacenter is run server with some task. However only one task may be active at one time across all datacenters. Jobslib solves this problem.

Main features are:

  • Ancestor for class which holds configuration.

  • Ancestor for container for shared resources, e.g. database connection.

  • Ancestor for class with task.

  • Configurable either from configuration file or from environmet variables.

  • Liveness – mechanism for exporting informations about health state of the task. Jobslib includes implementation which uses Consul.

  • Metrics – mechanism for exporting metrics. Jobslib includes implementation which uses InfluxDB.

  • One Instance Lock – lock, which allowes only one running instance at the same time. Jobslib includes implementation which uses Consul.

Installation

Installation from source code:

$ git clone https://github.com/seznam/jobslib.git
$ cd jobslib
$ python setup.py install

Installation from PyPi:

$ pip install jobslib

Tox is used for testing:

$ git clone https://github.com/seznam/jobslib.git
$ cd jobslib
$ pip install tox
$ tox --skip-missing-interpreters

Usage

Task is launched from command line using runjob command:

$ runjob [-s SETTINGS] [--disable-one-instance] [--run-once]
         [--sleep-interval SLEEP_INTERVAL] [--run-interval RUN_INTERVAL]
         [--keep-lock] [--release-on-error]
         task_cls

# Pass settings module using -s argument
$ runjob -s myapp.settings myapp.task.HelloWorldTask --run-once

# Pass settings module using environment variable
$ export JOBSLIB_SETTINGS_MODULE="myapp.settings"
$ runjob myapp.task.HelloWorldTask --run-once

If you want to write your own task, inherit BaseTask class and override BaseTask.task() method. According to your requirements inherit and override Config and/or Context and set settings module.

class HelloWorldTask(BaseTask):

    name = 'helloworld'
    description = 'prints hello world'

    def task(self):
        sys.stdout.write('Hello World!\n')
        sys.stdout.flush()

License

3-clause BSD

Documentation

https://seznam.github.io/jobslib/

Release files for jobslib 3.2.1

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

Source distribution (sdist)

Source distribution for jobslib 3.2.1
File Size Uploaded
jobslib-3.2.1.tar.gz 23.1 kB Details

Built distribution (wheel)

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

Total release size: 52.4 kB

Release files / jobslib-3.2.1.tar.gz

Download URL jobslib-3.2.1.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2dc1f73a4886a796361b3ed2388820702bb3deb843a47e98593a6ae5149ae304
BLAKE2b-256 checksum
How to use checksums
9b09c121bc2b45e0bb411f8d453b4817d9bc49f0324e72d054f71cd74af95020
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release files / jobslib-3.2.1-py3-none-any.whl

Download URL jobslib-3.2.1-py3-none-any.whl
Size 29.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca9f55f25bc0a589da8a4a9fc9bd048b0134d4978a33ad41e6dd196d01a296cd
BLAKE2b-256 checksum
How to use checksums
4c56f5c32bd79cb7e1daf2b5faef541f3250f13ec4d7fdc808e45242d5468dd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release history Release notifications | RSS feed

This release

3.2.1 This release

2 release files

3.2.0

2 release files

3.1.0

1 release file

3.0.5

1 release file

3.0.4

1 release file

3.0.3

1 release file

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

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