Skip to main content

fasttask_manager

Manager for fasttask

Installation

pip install fasttask_manager

Usage

Create a Manager

Synchronous Manager:

from fasttask_manager import Manager

m = Manager("127.0.0.1", port=8080)

Asynchronous Manager:

import asyncio
from fasttask_manager import AsyncManager

async def main():
    am = AsyncManager("127.0.0.1", port=8080)
    # use await
    result = await am.run(params)

Run a task

result = m.run(params)

Create a task and check result later

result_id = m.create_task(params)
# do something...
result = m.check(result_id)

Create a task and wait for result

result = m.create_and_wait_result(params)

Large results (offloaded to object storage)

当 FastTask 配置了 RESULT_TYPE=S3/AUTO 且结果较大时,/check 返回的 result 不再是结果本身,而是对象存储引用(result_type 为 "s3",含预签名下载地址)。 Manager 会自动处理这种情况,调用方拿到的始终是真实结果:

# create_and_wait_result 默认自动下载外置结果
result = m.create_and_wait_result(task_name, params)

# check 需要显式开启;默认原样返回带 result_type 的完整响应
resp = m.check(task_name, result_id)                      # 原始响应
resp = m.check(task_name, result_id, resolve_result=True)  # 自动下载后返回真实结果

# 也可以显式下载(传响应或直接传预签名地址)
result = m.download_result(resp)                    # 解析 JSON 并返回
m.download_result(resp, local_path="result.json")   # 流式落盘,返回文件路径

异步版本用法相同(await 即可):

result = await am.create_and_wait_result(task_name, params)
result = await am.check(task_name, result_id, resolve_result=True)
result = await am.download_result(resp, local_path="result.json")

注:预签名地址自带鉴权,下载时不会携带 Basic 凭据(否则会破坏签名)。

结果形态严格按服务端的 result_type 处理,不做静默兜底:

  • json / text:直接返回 result 内容(内联结果与错误/状态文本保持原行为)
  • s3:取引用里的下载地址并下载解析;引用格式不符、缺下载地址、下载失败均直接报错
  • 未知的 result_type、响应不是对象:直接报错(客户端与服务端版本不匹配)
  • 服务端未返回 result_type(旧版本):打印 warning 提醒尽快升级,并按内联结果处理

Upload a file

file_name = m.upload("/path/to/file.txt")

Download a file

m.download("file.txt", "/path/to/save.txt")

Revoke a task

m.revoke(result_id)

Configuration

Parameter Type Default Description
host str - Server host
protocol str "http" HTTP protocol
port int 80 Server port
tries int 5 Max retry attempts
delay int 3 Retry delay (seconds)
logger Logger None Custom logger
log_prefix str "" Log prefix
auth_user str "" Basic auth username
auth_passwd str "" Basic auth password
url_base_path str "" URL base path
req_timeout int 30 Request timeout (seconds)
simple_error_log bool True Simple error logging
verify_ssl bool False Verify SSL certificate

Architecture

BaseManager (shared initialization and utilities)
├── Manager (synchronous implementation)
│   ├── _req: uses requests library
│   └── _wait: uses time.sleep
└── AsyncManager (asynchronous implementation)
    ├── _req: uses httpx async client
    └── _wait: uses asyncio.sleep

Metadata

Release files for fasttask-manager 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fasttask-manager 0.6.1
File Size Uploaded
fasttask_manager-0.6.1.tar.gz 13.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fasttask-manager 0.6.1
File Interpreter ABI Platform
fasttask_manager-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / fasttask_manager-0.6.1.tar.gz

Download URL fasttask_manager-0.6.1.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e7d049d073a5d2c15f7ecf6c765ec99bd4fb11526c923309a72de1d727873e9f
BLAKE2b-256 checksum
How to use checksums
4a52f4e079121f888fd3b80496f0d0589607d53fc5c0a7687550c6be025541f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / fasttask_manager-0.6.1-py3-none-any.whl

Download URL fasttask_manager-0.6.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c73ccb964fe8b6c3356332b5e653d654d3016838a6d98f1d95c5a68aa8e0649
BLAKE2b-256 checksum
How to use checksums
43e34b60fe89ba2e3a41eca3d789e719fe0325b7c1c6675a328c59226a2dc0fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release history Release notifications | RSS feed

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

This release

0.6.1 This release

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.7

1 release file

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

2 release files

0.1.3

1 release file

0.1.2

1 release file

0.1.1

2 release files

0.1.0

1 release file

0.0.9

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page