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/

Download files

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

Source Distribution

jobslib-3.2.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

jobslib-3.2.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file jobslib-3.2.0.tar.gz.

File metadata

  • Download URL: jobslib-3.2.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for jobslib-3.2.0.tar.gz
Algorithm Hash digest
SHA256 e685d363e710882d71f4bcbdee10db8e5bae79c15655b137791b489f31bed530
MD5 d206ece7c0265d10b9b5297fa6a30adc
BLAKE2b-256 de17880dda102a8792798049c3e59dd3c7b6fb13c654e5edf054cf8ac322e59b

See more details on using hashes here.

File details

Details for the file jobslib-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: jobslib-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for jobslib-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68d5014ef524517e2c470cbac54d9d5a9825e4bf3511262b6c28f80fe5b7e825
MD5 c92c95565c777bca1689a371fdf3334c
BLAKE2b-256 39587add65b5bc7934611fb3971bb910c14bb5c430893dec06cd569d07dee24e

See more details on using hashes here.

Release history Release notifications | RSS feed

3.2.1

2 files

This release

3.2.0 This release

2 files

3.1.0

1 file

3.0.5

1 file

3.0.4

1 file

3.0.3

1 file

3.0.2

1 file

3.0.1

1 file

3.0.0

1 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