Skip to content

Commit 8423523

Browse files
committed
Version 1.19.0.0
1 parent da0e35b commit 8423523

File tree

8 files changed

+827
-741
lines changed

8 files changed

+827
-741
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ executors:
88
parameters:
99
v:
1010
type: string
11-
default: "3.11"
11+
default: "3.12"
1212

1313
docker:
1414
- image: cimg/python:<< parameters.v >>
@@ -105,7 +105,7 @@ jobs:
105105
deploy:
106106
executor: bitcart/docker-python
107107
docker:
108-
- image: cimg/python:3.11
108+
- image: cimg/python:3.12
109109
steps:
110110
- checkout
111111

@@ -129,9 +129,9 @@ workflows:
129129
matrix:
130130
parameters:
131131
v:
132-
- "3.11"
133132
- "3.12"
134133
- "3.13"
134+
- "3.14"
135135

136136
- bitcart/functional-tests:
137137
name: functional-tests

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-merge-conflict
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: v0.12.2
7+
rev: v0.14.1
88
hooks:
99
- id: ruff
1010
- id: ruff-format
1111
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v5.0.0
12+
rev: v6.0.0
1313
hooks:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
@@ -37,3 +37,7 @@ repos:
3737
language: node
3838
require_serial: true
3939
entry: npx prettier --write --ignore-unknown
40+
- repo: https://github.com/astral-sh/uv-pre-commit
41+
rev: 0.9.4
42+
hooks:
43+
- id: uv-lock

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
build:
44
os: ubuntu-22.04
55
tools:
6-
python: "3.11"
6+
python: "3.12"
77
jobs:
88
post_create_environment:
99
- pip install uv

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Latest changes
44

5+
## 1.19.0.0
6+
7+
Require Python 3.12+
8+
9+
Support Python 3.14
10+
11+
Better management of client session closure
12+
513
## 1.18.0.0
614

715
Electrums upgrade: `add_request` no longer creates a lightning invoice as well, use `add_invoice` as you should have always been doing

bitcart/providers/jsonrpcrequests.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import contextlib
3+
import weakref
34
from collections.abc import Callable
45
from typing import Any
56
from urllib.parse import urljoin
@@ -25,6 +26,18 @@ def create_request(method: str, *args: Any, **kwargs: Any) -> dict:
2526
return request(method, params) # type: ignore
2627

2728

29+
def _cleanup_sessions(sessions: dict[asyncio.AbstractEventLoop, aiohttp.ClientSession]) -> None:
30+
loop = get_event_loop()
31+
for session in list(sessions.values()):
32+
if session is None or session.closed:
33+
continue
34+
if loop.is_running():
35+
loop.create_task(session.close())
36+
else:
37+
loop.run_until_complete(session.close())
38+
sessions.clear()
39+
40+
2841
class RPCProxy:
2942
def __init__(
3043
self,
@@ -42,13 +55,14 @@ def __init__(
4255
self.xpub = xpub
4356
self.proxy = proxy
4457
self.verify = verify
45-
self._connector_class = aiohttp.TCPConnector
58+
self._connector_class: type[aiohttp.BaseConnector] = aiohttp.TCPConnector
4659
self._connector_init: dict[str, Any] = {"ssl": self.verify}
4760
self._spec = {"exceptions": {"-32600": {"exc_name": "UnauthorizedError", "docstring": "Unauthorized"}}}
4861
self._spec_valid = False
4962
self._sessions: dict[asyncio.AbstractEventLoop, aiohttp.ClientSession] = {}
5063
if session is not None:
5164
self._sessions[get_event_loop()] = session
65+
self._finalizer = weakref.finalize(self, _cleanup_sessions, self._sessions)
5266

5367
@property
5468
def session(self) -> aiohttp.ClientSession:
@@ -65,7 +79,7 @@ def init_proxy(self) -> None:
6579
from aiohttp_socks.utils import parse_proxy_url
6680

6781
proxy_type, host, port, username, password = parse_proxy_url(self.proxy)
68-
self._connector_class = ProxyConnector # type: ignore
82+
self._connector_class = ProxyConnector
6983
self._connector_init.update(
7084
proxy_type=proxy_type,
7185
host=host,
@@ -133,14 +147,6 @@ async def wrapper(*args: Any, **kwargs: Any) -> Any:
133147

134148
return wrapper
135149

136-
async def _close(self) -> None:
137-
for session in self._sessions.values():
138-
if session is not None:
139-
await session.close()
140-
141-
def __del__(self) -> None:
142-
loop = get_event_loop()
143-
if loop.is_running():
144-
loop.create_task(self._close())
145-
else:
146-
loop.run_until_complete(self._close())
150+
async def close(self) -> None:
151+
if self._finalizer.alive:
152+
self._finalizer()

bitcart/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "1.18.0.0"
1+
VERSION = "1.19.0.0"

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ description = "Bitcart coins support library"
99
readme = "README.md"
1010
license = "MIT"
1111
authors = [{ name = "MrNaif2018", email = "chuff184@gmail.com" }]
12-
requires-python = ">=3.11"
12+
requires-python = ">=3.12"
1313
classifiers = [
1414
"Development Status :: 5 - Production/Stable",
1515
"Intended Audience :: Developers",
1616
"Topic :: Software Development :: Build Tools",
1717
"License :: OSI Approved :: MIT License",
1818
"Programming Language :: Python :: 3",
19-
"Programming Language :: Python :: 3.11",
2019
"Programming Language :: Python :: 3.12",
2120
"Programming Language :: Python :: 3.13",
21+
"Programming Language :: Python :: 3.14",
2222
]
2323
keywords = ["electrum", "daemon", "bitcart", "bitcartcc"]
2424
dependencies = ["jsonrpcclient", "aiohttp", "universalasync"]
@@ -61,7 +61,7 @@ packages = ["bitcart"]
6161
path = "bitcart/version.py"
6262

6363
[tool.ruff]
64-
target-version = "py311"
64+
target-version = "py312"
6565
line-length = 127
6666

6767
[tool.ruff.lint]

0 commit comments

Comments
 (0)