This repository has been archived by the owner. It is now read-only.
Runs things in the background.
Branch: master
Clone or download
Latest commit 0cb39fb Sep 6, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Pipfile remove decorator decorator Sep 2, 2017
README.rst Update README.rst Sep 5, 2017
background.py Merge pull request #5 from walkerlala/patch-1 Sep 6, 2017
setup.py rely on futures Sep 3, 2017

README.rst

Background: run stuff in the backround

"An elegant decorator-based abstraction around Python 3's concurrent.futures ThreadPoolExecutor class"

—Simon Willison

This module makes it stupidly simple to run things in the background of your application, be it a CLI app, or a web app.

https://farm5.staticflickr.com/4296/36137232912_7276365f2e_k_d.jpg

Basic Usage

import time

import background


@background.task
def work():
    # Do something expensive here.
    time.sleep(10)


for _ in range(100):
    work()

Advanced Usage

import time

import background

# Use 40 background threads.
background.n = 40


@background.task
def work():
    time.sleep(10)

@background.callback
def work_callback(future):
    print(future)


for _ in range(100):
    work()

Installation

$ pipenv install background
✨🍰✨