Git Product home page Git Product logo

cdrx_faktory_worker_python's Introduction

Python worker for Faktory

Overview

This project is a complete worker and client implementation for the Faktory job server. You can use it to either consume jobs from Faktory or push jobs to the Faktory server to be processed.

Requires Python 3.7+.

Supported Faktory Versions

❌ 0.5.0
✅ 0.6.0+
✅ 0.7.0+
✅ 0.8.0+
✅ 1.0.0+

Features

  • Creating a worker to run jobs from Faktory
  • Concurrency (with multiple processes or threads with the use_threads=True option)
  • Pushing work to Faktory from Python (with retries, custom metadata and scheduled support)
  • Pushing exception / errors from Python back up to Faktory
  • Sends worker status back to Faktory
  • Supports quiet and teminate from the Faktory web UI
  • Password authentication
  • TLS support
  • Graceful worker shutdown (ctrl-c will allow 15s for pending jobs to finish)

Todo

  • Documentation (in progress, help would be appreciated)
  • Tests (in progress, help would be appreciated)
  • Django integration (./manage.py runworker and app/tasks.py support)

Installation

pip install faktory

Pushing Work to Faktory

There is a client context manager that you can use like this:

import faktory

with faktory.connection() as client:
    client.queue('test', args=(1, 2))
    client.queue('test', args=(4, 5), queue='other')

test doesn't need to be implemented by the Python worker, it can be any of the available worker implementations.

Worker Example

Sample worker:

from faktory import Worker

def your_function(x, y):
    return x + y

w = Worker(queues=['default'], concurrency=1)
w.register('test', your_function)

w.run()  # runs until control-c or worker shutdown from Faktory web UI

Connection to Faktory

faktory_worker_python uses this format for the Faktory URL:

tcp://:password@localhost:7419

or with TLS:

tcp+tls://:password@localhost:7419

If the environment variable FAKTORY_URL is set, that is used. Otherwise you can pass the server URL in to the Worker or Client constructor, like this:

w = Worker(faktory="tcp://localhost:7419")

Logging

The worker users Python's built in logging module, which you can enable like this before calling .run():

import logging
logging.basicConfig(level=logging.DEBUG)

cdrx_faktory_worker_python's People

Contributors

alexisprince1994 avatar cdrx avatar gowabash avatar rlankfo avatar schniz avatar shatgupt avatar tswayne avatar valo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.