跳转到主要内容

它做的是它所说的。

项目描述

https://img.shields.io/pypi/pyversions/background.svg https://github.com/ParthS007/background/workflows/CI/badge.svg

Background

它在后台运行东西。

“围绕Python 3的concurrent.futures.ThreadPoolExecutor类的一个优雅的装饰器抽象”

—Simon Willison

此模块使得在您的应用程序后台运行东西变得极其简单,无论是命令行应用程序还是Web应用程序。

基本用法

import time

import background


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


for _ in range(100):
    work()

高级用法

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()

安装

$ pipenv install background
✨🍰✨

项目详情


下载文件

下载您平台所需的文件。如果您不确定该选择哪一个,请了解有关安装包的更多信息。

源分发

background-0.2.1.tar.gz (3.1 kB 查看哈希值)

上传时间

构建分发

background-0.2.1-py3-none-any.whl (2.2 kB 查看哈希值)

上传时间 Python 3

由以下支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误记录StatusPageStatusPage状态页面