Skip to content

Commit 3ba42e6

Browse files
committed
Upgraded pyo3 deps
Signed-off-by: chandr-andr (Kiselev Aleksandr) <chandr@chandr.net>
1 parent 0b38248 commit 3ba42e6

14 files changed

+204
-77
lines changed

Cargo.lock

Lines changed: 35 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ pyo3 = { version = "*", features = [
1414
"chrono",
1515
"experimental-async",
1616
"rust_decimal",
17+
"py-clone",
18+
"gil-refs",
19+
"macros",
1720
] }
18-
pyo3-asyncio = { git = "https://github.com/chandr-andr/pyo3-asyncio.git", version = "0.20.0", features = [
21+
pyo3-async-runtimes = { git = "https://github.com/chandr-andr/pyo3-async-runtimes.git", branch = "main", features = [
1922
"tokio-runtime",
2023
] }
24+
2125
tokio = { version = "1.35.1", features = ["full"] }
2226
thiserror = "1.0.56"
2327
bytes = "1.5.0"

python/tests/test_binary_copy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
import typing
33
from io import BytesIO
44

5+
import pytest
56
from pgpq import ArrowToPostgresBinaryEncoder
67
from pyarrow import parquet
78

89
from psqlpy import ConnectionPool
910

11+
pytestmark = pytest.mark.anyio
12+
1013

1114
async def test_binary_copy_to_table_in_connection(
1215
psql_pool: ConnectionPool,

python/tests/test_connection.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,16 @@ async def test_connection_cursor(
142142
"""Test cursor from Connection."""
143143
connection = await psql_pool.connection()
144144
cursor: Cursor
145-
all_results: list[dict[typing.Any, typing.Any]] = []
146-
147-
async with connection.transaction(), connection.cursor(
148-
querystring=f"SELECT * FROM {table_name}",
149-
) as cursor:
150-
async for cur_res in cursor:
151-
all_results.extend(cur_res.result())
152-
153-
assert len(all_results) == number_database_records
145+
transaction = connection.transaction()
146+
await transaction.begin()
147+
cursor = connection.cursor(querystring=f"SELECT * FROM {table_name}")
148+
await cursor.start()
149+
await cursor.close()
150+
await transaction.commit()
151+
152+
# async with connection.transaction(), connection.cursor(
153+
# ) as cursor:
154+
# async for cur_res in cursor:
154155

155156

156157
async def test_connection_async_context_manager(

src/driver/common_options.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::time::Duration;
33
use deadpool_postgres::RecyclingMethod;
44
use pyo3::{pyclass, pymethods};
55

6-
#[pyclass]
7-
#[derive(Clone, Copy)]
6+
#[pyclass(eq, eq_int)]
7+
#[derive(Clone, Copy, PartialEq)]
88
pub enum ConnRecyclingMethod {
99
Fast,
1010
Verified,
@@ -22,8 +22,8 @@ impl ConnRecyclingMethod {
2222
}
2323
}
2424

25-
#[pyclass]
26-
#[derive(Clone, Copy)]
25+
#[pyclass(eq, eq_int)]
26+
#[derive(Clone, Copy, PartialEq)]
2727
pub enum LoadBalanceHosts {
2828
/// Make connection attempts to hosts in the order provided.
2929
Disable,
@@ -41,8 +41,8 @@ impl LoadBalanceHosts {
4141
}
4242
}
4343

44-
#[pyclass]
45-
#[derive(Clone, Copy)]
44+
#[pyclass(eq, eq_int)]
45+
#[derive(Clone, Copy, PartialEq)]
4646
pub enum TargetSessionAttrs {
4747
/// No special properties are required.
4848
Any,
@@ -63,7 +63,7 @@ impl TargetSessionAttrs {
6363
}
6464
}
6565

66-
#[pyclass]
66+
#[pyclass(eq, eq_int)]
6767
#[derive(Clone, Copy, PartialEq)]
6868
pub enum SslMode {
6969
/// Do not use TLS.
@@ -110,6 +110,7 @@ pub struct KeepaliveConfig {
110110
#[pymethods]
111111
impl KeepaliveConfig {
112112
#[new]
113+
#[pyo3(signature = (idle, interval=None, retries=None))]
113114
fn build_config(idle: u64, interval: Option<u64>, retries: Option<u32>) -> Self {
114115
let interval_internal = interval.map(Duration::from_secs);
115116
KeepaliveConfig {
@@ -120,8 +121,8 @@ impl KeepaliveConfig {
120121
}
121122
}
122123

123-
#[pyclass]
124-
#[derive(Clone, Copy)]
124+
#[pyclass(eq, eq_int)]
125+
#[derive(Clone, Copy, PartialEq)]
125126
pub enum CopyCommandFormat {
126127
TEXT,
127128
CSV,

0 commit comments

Comments
 (0)