Background
It runs stuff in the background.
“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.
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)
return "Done!"
@background.callback
def work_callback(future):
print(future.result())
for _ in range(100):
work()
Installation
$ pipenv install background ✨🍰✨
Release files for background 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| background-0.2.1.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| background-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.3 kB
Release files / background-0.2.1.tar.gz
| Download URL | background-0.2.1.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a5ed40b4a2a9f3340b1402862725d35016dc2490f95d89a2de47c3ddf215b91
|
|
BLAKE2b-256 checksum How to use checksums |
b141d6122c8e4bb280b2182098d77554d00016b6ffe54201cd3fac7f52fe9df2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
|
Release files / background-0.2.1-py3-none-any.whl
| Download URL | background-0.2.1-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c230e2813c773f93ecae54281ce6b1b425c895c24599cc203b7f137e4d7c4802
|
|
BLAKE2b-256 checksum How to use checksums |
c74501a33c692ce9f22214cad440f34704ed74e56b6f21d90e71aa595b3c2b72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
|