A unified I/O management toolkit supporting threads, coroutines, files, databases, and data formats
Project description
🧩 Gatling Utility Library
Gatling is a lightweight asynchronous utility library built on aiohttp, asyncio, and threading.
It provides concurrent HTTP requests, coroutine-thread orchestration, data pipelines, and handy file utilities.
📦 Installation
pip install gatling
📁 Module Overview
| Module | Description |
|---|---|
http_client.py |
Async/sync HTTP request handling |
file_utils.py |
Common file read/write helpers |
taskflow_manager.py |
Multi-stage task pipeline system |
watch.py |
Stopwatch and timing tools |
🧵 1. Process & Coroutine & Thread Manager
A hybrid process + thread + coroutine manager that can run both sync and async tasks concurrently.
Example
from gatling.runtime.taskflow_manager import TaskFlowManager
from gatling.storage import MemoryQueue
from gatling.utility.xprint import check_globals_pickable
from gatling.vtasks.sample_tasks import fake_iter_disk, fake_fctn_disk, async_fake_iter_net, async_fake_fctn_net, fake_fctn_cpu, fake_iter_cpu
if __name__ == '__main__':
pass
# ---------- Build and run the pipeline ----------
check_globals_pickable()
if True:
q_wait = MemoryQueue()
# you can push to quque at here
for i in range(10):
q_wait.put(i + 1)
tfm = TaskFlowManager(q_wait, retry_on_error=False)
# or you can push to queue at here
with tfm.execute(log_interval=1):
tfm.register_process(fake_fctn_cpu, worker=2)
tfm.register_coroutine(async_fake_fctn_net, worker=5)
tfm.register_thread(fake_fctn_disk, worker=2)
tfm.register_process(fake_iter_cpu, worker=2)
tfm.register_coroutine(async_fake_iter_net, worker=8)
tfm.register_thread(fake_iter_disk, worker=8)
# or you can push to queue at here
q_done = tfm.get_qdone()
results = list(q_done)
print(f"\n=== Final Results ({len(results)})===")
🌐 2. HTTP Client Module
File: gatling/utility/http_client.py
Provides unified async/sync HTTP request helpers supporting GET, POST, PUT, and DELETE.
Example
from gatling.utility.http_fetch_fctns import sync_fetch_http, async_fetch_http, fwrap
import asyncio
target_url = "https://httpbin.org/get"
print("--- Synchronous request ---")
result, status, size = sync_fetch_http(target_url, rtype="json")
print(status, size, result)
print("--- Asynchronous request ---")
result, status, size = asyncio.run(fwrap(async_fetch_http, target_url=target_url, rtype="json"))
print(status, size, result)
Main functions
async_fetch_http(...): Generic async HTTP fetcherfwrap(...): Safely manages aiohttp session lifecyclesync_fetch_http(...): Simple synchronous wrapper (for scripts)
💾 3. File Utility Module
File: gatling/utility/io_fctns.py
Convenient helpers for reading and writing JSON, JSONL, Pickle, TOML, text, and byte files.
Example
from gatling.utility.io_fctns import *
save_json({"a": 1}, "data.json")
print(read_json("data.json"))
remove_file("data.json")
save_jsonl([{"x": 1}, {"x": 2}], "data.jsonl")
print(read_jsonl("data.jsonl"))
remove_file("data.jsonl")
save_text("Hello world", "msg.txt")
print(read_text("msg.txt"))
remove_file("msg.txt")
Main functions
save_json / read_jsonsave_jsonl / read_jsonlsave_text / read_textsave_pickle / read_picklesave_bytes / read_bytesread_tomlremove_file
⏱️ 4. Watch Utility
File: gatling/utility/watch.py
A simple stopwatch for timing operations, plus a decorator for measuring function execution time.
Example
from gatling.utility.watch import Watch, watch_time
import time
@watch_time
def slow_func():
time.sleep(1)
slow_func()
w = Watch()
time.sleep(0.5)
print("Δt:", w.see_seconds(), "Total:", w.total_seconds())
Main items
Watch: Manual stopwatch class for measuring intervalswatch_time: Decorator that prints function execution time
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gatling-0.3.0.18.tar.gz.
File metadata
- Download URL: gatling-0.3.0.18.tar.gz
- Upload date:
- Size: 46.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2ee737c4169100025db60794c225bfa0c50c38d4f4855f3559c20d796bb1816
|
|
| MD5 |
1e60b43e0b0e6521275110d45312bb34
|
|
| BLAKE2b-256 |
78fd2c630b1797a0a75417e0078c25e964e0f818a62ddb3e72c379195f0310bf
|
File details
Details for the file gatling-0.3.0.18-py3-none-any.whl.
File metadata
- Download URL: gatling-0.3.0.18-py3-none-any.whl
- Upload date:
- Size: 73.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38f990922e344ccbdc8171961c2c8a73128afaa2340c71f36e69bff931f74269
|
|
| MD5 |
e4827538729cdb628b6e98b1e7d44649
|
|
| BLAKE2b-256 |
f5f3128e9d70db89422b44a15fb2633bc3c7608db56aa0b4ca3bd499f5ea4f4e
|