semvec/pypi-packages huggingface dataset:
tnm-circuit-breaker 0.2.2
A ligthweight circuit breaker implementation for Python.
Requires Python: >=3.11
Keywords: breaker, circuit, circuit breaker, redis

# tnm-circuit-breaker

A lightweight Python circuit breaker for protecting downstream systems.

> See **[USAGE](https://github.com/tnm-circuit-breaker/USAGE.md)** for full examples.

---

## Quick summary

* Purpose: protect downstream services (i.e., Elasticsearch, RabbitMQ, Kafka, Postgres, external HTTP APIs, ...) from
  cascading failures.
* Backends:

    * `local`: no extra dependencies needed
    * `redis`: distributed backend using Redis for atomic operations.

---

## Install

```bash
# core package
pip install tnm-circuit-breaker

# redis support
pip install "tnm-circuit-breaker[redis]"

```

---

## `CircuitBreaker` Public APIs

```python
class CircuitBreaker:
    def record_failure(*args) -> int: ...

    def last_failure(*args): ...

    def record_success(*args) -> None: ...

    def protect(*args): ...

    # a decorator

    def execute(*args): ...

    async def execute_async(*args): ...

    def raise_circuit_open_error(*args): ...

```

---

## Quick Usage

### Using the `protect` decorator

```py
from tnm.circuit import get_breaker
from tnm.circuit.exceptions import CircuitOpenError

breaker = get_breaker()  # defaults


@breaker.protect("service-name")
def my_function():
    pass


try:
    my_function()
except CircuitOpenError:
    ...
    # handle circuit open
```

### Using the `execute` method

```py
from tnm.circuit import get_breaker
from tnm.circuit.exceptions import CircuitOpenError

breaker = get_breaker()  # defaults


def my_function():
    pass


try:
    breaker.execute("service-name", my_function)
except CircuitOpenError:
    ...
    # handle circuit open
```

### Using the `execute_async` method

```py
import asyncio
from tnm.circuit import get_breaker
from tnm.circuit.exceptions import CircuitOpenError

breaker = get_breaker()  # defaults


async def my_async_function():
    pass


async def main():
    try:
        await breaker.execute_async("service-name", my_async_function)
    except CircuitOpenError:
        ...
        # handle circuit open


if __name__ == "__main__":
    asyncio.run(main())
```

---

## Exceptions

All library exceptions inherit from a small, focused hierarchy:

* `CircuitError`: Base exception for all circuit breaker errors.
* `CircuitBackendError`: backend operational issues.
* `CircuitOpenError`: raised when an operation is attempted while a service's circuit is open.
* `ReturnValuePolicyError`: raised when a return-value rule matched; contains `.retval` and `.retval_policy`.

Handle `CircuitOpenError` or `ReturnValuePolicyError` as an expected operational outcome.

When catching, inspect `.args` or `.__cause__` for low-level detail.

---

## Contributing

Contributions welcome.

---

## License

MIT
regress 2025.10.1
Python bindings to Rust's regress ECMA regular expressions library
Requires Python: >=3.10
Keywords: regex, rust, javascript, ecmascript, regular expressions

===========
``regress``
===========

|PyPI| |Pythons| |CI|

.. |PyPI| image:: https://img.shields.io/pypi/v/regress.svg
  :alt: PyPI version
  :target: https://pypi.org/project/regress/

.. |Pythons| image:: https://img.shields.io/pypi/pyversions/regress.svg
  :alt: Supported Python versions
  :target: https://pypi.org/project/regress/

.. |CI| image:: https://github.com/Julian/regress/workflows/CI/badge.svg
  :alt: Build status
  :target: https://github.com/Julian/regress/actions?query=workflow%3ACI


Python bindings to the Rust `regress <https://docs.rs/regress/latest/regress/>`_ crate, exposing ECMA regular expressions.


.. code:: python

    >>> from regress import Regex
    >>> regex = Regex(r"\d{4}")
    >>> regex.find("2020-20-05") is not None
    True
qtl-ctp-api 6.7.11
QTL CTP API
Requires Python: >=3.8

# QTL CTP API

> qtl-ctp-api

又一个面向 Python 的 CTP 客户端 API 包

**Only for Linux**

## 特点

- 使用 nanobind 作为 C++ 到 Python 的绑定库，相对于 pybind11 ，nanobind 效率更高，其官方文档中所述：
    > More concretely, benchmarks show up to ~4× faster compile time, ~5× smaller binaries, and ~10× lower runtime overheads compared to pybind11. nanobind also outperforms Cython in important metrics (3-12× binary size reduction, 1.6-4× compilation time reduction, similar runtime performance).

- 在 C++ 端另外实现了一个任务队列，防止因为 Python 端处理不及时导致的 CTP 库内部运行时队列溢出异常。

- 使用 scikit_build + CMake 作为包构建工具，安装、编译、部署非常方便。

- 使用脚本生成 C++ 代码，其中可以配置需要实现绑定的方法，提高编译速度以及去掉运行时不必要的代码。

- 使用 iconv 进行字符编码转换。当前 libiconv 已经包含到 libc 中，无需再通过 locale 、操作 locale-gen 的方式进行转换。

- C++ 代码方面尽量按照新标准的 C++ 代码标准实现，利用现代 C++ 的各种优势。

- 只面向 Linux ，无需增加很多冗余的跨平台代码与配置。

## Install

*需要系统内有 C++ 编译相关工具，对于 Ubuntu Server 可以通过 `sudo apt install build-essential` 安装*

```
pip install qtl-ctp-api
```

## Quick Start

`./tests` 目录下有简单使用范例

- test_md.py 行情获取相关
- test_td.py 交易柜台相关

## CTP version

- CTP: v6.7.11