Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Feature]: Thread-safe Multi-Instance API Client with Configuration Isolation

未关闭
#388 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
api, payments

调研方向

首先映射顶层导出的对象、各个 API 处理器子模块和 HTTP 客户端入口点,以了解单例状态和配置的存放位置。检查 ListTerminalsProtocol workaround 和现有注解;完成的标准是独立配置可以并发工作,并且静态分析器能够理解客户端 API。

由索引模型根据 Issue 内容生成。

描述

Feature needs response
Feature summary

Multi‑instance, thread‑safe API client with better typing

Problem statement
Background

The current Python client uses a singleton pattern for each API handler and the HTTP client. In multithreaded environments (e.g., UWSGI) this leads to thread‑safety issues and makes it impossible to use different credentials/settings for separate services (e.g., ECOM vs. POS).

A workaround is already in place: importing individual API parts from submodules and instantiating a separate HTTP client for each use‑case. However, the library’s interface still encourages the global singleton, which is not safe.

Proposed improvements
Area Desired change
Instance isolation Remove the singleton pattern and allow callers to create multiple independent client instances. Each instance should accept its own configuration (API endpoint, authentication keys, HTTP client, etc.).
Documentation Clearly document that the top‑level exported objects are global singletons and discourage their use in multi‑tenant or concurrent workflows. Provide examples of per‑instance creation.
Thread safety Ensure no shared mutable state lives inside the client or its handler objects, so concurrent requests with different configs are safe.
Type hints Improve static typing:
• Functions that currently return AdyenResult | None | Unknown actually raise inside helper functions. Either raise the exception directly or return a clear Union with explicit error types.
• Provide type stubs / .pyi files or refined type annotations so tools like basedpyright and mypy can understand the API signatures.
• Example: Replace the ad‑hoc ListTerminalsProtocol workaround with a real protocol exposed in the library.
My comments (for reference)
  • The library is generated via an API generator, so a complete rewrite is not realistic.
  • Instantiating small objects in Python has negligible memory overhead—no performance penalty.
  • I am available for hire, on a consulting basis.
Proposed solution

Goal: Get a library that supports multiple concurrent clients with distinct configurations while providing robust typing for static analysis tools. This solves the thread‑safety problem and makes the ECOM/POS multi‑tenant use‑case straightforward.

Alternatives considered

No response

Additional context

No response

主要语言
Python
星标
68
派生
51
平均合并
2 小时 3 分钟
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Adyen/adyen-python-api-library 的其他 Issue

查看 Adyen/adyen-python-api-library 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。