Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kennethreitz/background
Runs things in the background.
https://github.com/kennethreitz/background
Last synced: 3 months ago
JSON representation
Runs things in the background.
- Host: GitHub
- URL: https://github.com/kennethreitz/background
- Owner: kennethreitz
- Fork: true (ParthS007/background)
- Created: 2021-01-19T18:55:47.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-12T19:31:56.000Z (over 2 years ago)
- Last Synced: 2024-07-18T01:54:11.801Z (4 months ago)
- Size: 19.5 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- starred-awesome - background - Runs things in the background. (Python)
README
.. image:: https://img.shields.io/pypi/pyversions/background.svg
:target: https://pypi.org/pypi/background.. image:: https://github.com/ParthS007/background/workflows/CI/badge.svg
:target: https://github.com/ParthS007/background/actionsBackground
=======================================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
-----------.. code:: python
import time
import background
@background.task
def work():
# Do something expensive here.
time.sleep(10)for _ in range(100):
work()Advanced Usage
--------------.. code:: python
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
✨🍰✨