Skip to content

Commit 007296d

Browse files
committed
LISTEN/NOTIFY funcionality
Signed-off-by: chandr-andr (Kiselev Aleksandr) <chandr@chandr.net>
1 parent f6104bc commit 007296d

File tree

12 files changed

+57
-80
lines changed

12 files changed

+57
-80
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ repos:
5858
- clippy::all
5959
- -W
6060
- clippy::pedantic
61-
- -D
62-
- warnings
6361

6462
- id: check
6563
types:

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@ crate-type = ["cdylib"]
1010

1111
[dependencies]
1212
deadpool-postgres = { git = "https://github.com/chandr-andr/deadpool.git", branch = "psqlpy" }
13-
pyo3 = { version = "*", features = [
14-
"chrono",
15-
"experimental-async",
16-
"rust_decimal",
17-
"py-clone",
18-
"gil-refs",
19-
"macros",
20-
] }
21-
pyo3-async-runtimes = { git = "https://github.com/chandr-andr/pyo3-async-runtimes.git", branch = "main", features = [
13+
pyo3 = { version = "0.23.4", features = ["chrono", "experimental-async", "rust_decimal", "py-clone", "macros"] }
14+
pyo3-async-runtimes = { git = "https://github.com/chandr-andr/pyo3-async-runtimes.git", branch = "psqlpy", features = [
2215
"tokio-runtime",
2316
] }
2417

src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ pub fn add_module(
2424
child_mod_name: &'static str,
2525
child_mod_builder: impl FnOnce(Python<'_>, &Bound<'_, PyModule>) -> PyResult<()>,
2626
) -> PyResult<()> {
27-
let sub_module = PyModule::new_bound(py, child_mod_name)?;
27+
let sub_module = PyModule::new(py, child_mod_name)?;
2828
child_mod_builder(py, &sub_module)?;
2929
parent_mod.add_submodule(&sub_module)?;
30-
py.import_bound("sys")?.getattr("modules")?.set_item(
30+
py.import("sys")?.getattr("modules")?.set_item(
3131
format!("{}.{}", parent_mod.name()?, child_mod_name),
3232
sub_module,
3333
)?;

src/driver/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl Connection {
177177
let (is_exception_none, py_err) = pyo3::Python::with_gil(|gil| {
178178
(
179179
exception.is_none(gil),
180-
PyErr::from_value_bound(exception.into_bound(gil)),
180+
PyErr::from_value(exception.into_bound(gil)),
181181
)
182182
});
183183

src/driver/cursor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl Cursor {
179179
self_.closed,
180180
self_.cursor_name.clone(),
181181
exception.is_none(gil),
182-
PyErr::from_value_bound(exception.into_bound(gil)),
182+
PyErr::from_value(exception.into_bound(gil)),
183183
)
184184
});
185185

src/driver/listener/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Listener {
104104
(
105105
self_.connection.db_client(),
106106
exception.is_none(gil),
107-
PyErr::from_value_bound(exception.into_bound(gil)),
107+
PyErr::from_value(exception.into_bound(gil)),
108108
)
109109
});
110110

src/driver/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl Transaction {
236236
(
237237
self_.check_is_transaction_ready(),
238238
exception.is_none(gil),
239-
PyErr::from_value_bound(exception.into_bound(gil)),
239+
PyErr::from_value(exception.into_bound(gil)),
240240
self_.db_client.clone(),
241241
)
242242
});

src/driver/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub fn build_manager(
226226
/// 2) extract boolean
227227
pub fn is_coroutine_function(function: Py<PyAny>) -> RustPSQLDriverPyResult<bool> {
228228
let is_coroutine_function: bool = Python::with_gil(|py| {
229-
let inspect = py.import_bound("inspect")?;
229+
let inspect = py.import("inspect")?;
230230

231231
let is_cor = inspect
232232
.call_method1("iscoroutinefunction", (function,))

src/exceptions/python_errors.rs

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use pyo3::{
33
types::{PyModule, PyModuleMethods},
44
Bound, PyResult, Python,
55
};
6+
67
// Main exception.
78
create_exception!(
89
psqlpy.exceptions,
@@ -146,108 +147,93 @@ create_exception!(psqlpy.exceptions, SSLError, RustPSQLDriverPyBaseError);
146147
pub fn python_exceptions_module(py: Python<'_>, pymod: &Bound<'_, PyModule>) -> PyResult<()> {
147148
pymod.add(
148149
"RustPSQLDriverPyBaseError",
149-
py.get_type_bound::<RustPSQLDriverPyBaseError>(),
150+
py.get_type::<RustPSQLDriverPyBaseError>(),
150151
)?;
151152

152153
pymod.add(
153154
"BaseConnectionPoolError",
154-
py.get_type_bound::<BaseConnectionPoolError>(),
155+
py.get_type::<BaseConnectionPoolError>(),
155156
)?;
156157
pymod.add(
157158
"ConnectionPoolBuildError",
158-
py.get_type_bound::<ConnectionPoolBuildError>(),
159+
py.get_type::<ConnectionPoolBuildError>(),
159160
)?;
160161
pymod.add(
161162
"ConnectionPoolConfigurationError",
162-
py.get_type_bound::<ConnectionPoolConfigurationError>(),
163+
py.get_type::<ConnectionPoolConfigurationError>(),
163164
)?;
164165
pymod.add(
165166
"ConnectionPoolExecuteError",
166-
py.get_type_bound::<ConnectionPoolExecuteError>(),
167+
py.get_type::<ConnectionPoolExecuteError>(),
167168
)?;
168169

169-
pymod.add(
170-
"BaseConnectionError",
171-
py.get_type_bound::<BaseConnectionError>(),
172-
)?;
170+
pymod.add("BaseConnectionError", py.get_type::<BaseConnectionError>())?;
173171
pymod.add(
174172
"ConnectionExecuteError",
175-
py.get_type_bound::<ConnectionExecuteError>(),
173+
py.get_type::<ConnectionExecuteError>(),
176174
)?;
177175
pymod.add(
178176
"ConnectionClosedError",
179-
py.get_type_bound::<ConnectionClosedError>(),
177+
py.get_type::<ConnectionClosedError>(),
180178
)?;
181179

182180
pymod.add(
183181
"BaseTransactionError",
184-
py.get_type_bound::<BaseTransactionError>(),
182+
py.get_type::<BaseTransactionError>(),
185183
)?;
186184
pymod.add(
187185
"TransactionBeginError",
188-
py.get_type_bound::<TransactionBeginError>(),
186+
py.get_type::<TransactionBeginError>(),
189187
)?;
190188
pymod.add(
191189
"TransactionCommitError",
192-
py.get_type_bound::<TransactionCommitError>(),
190+
py.get_type::<TransactionCommitError>(),
193191
)?;
194192
pymod.add(
195193
"TransactionRollbackError",
196-
py.get_type_bound::<TransactionRollbackError>(),
194+
py.get_type::<TransactionRollbackError>(),
197195
)?;
198196
pymod.add(
199197
"TransactionSavepointError",
200-
py.get_type_bound::<TransactionSavepointError>(),
198+
py.get_type::<TransactionSavepointError>(),
201199
)?;
202200
pymod.add(
203201
"TransactionExecuteError",
204-
py.get_type_bound::<TransactionExecuteError>(),
202+
py.get_type::<TransactionExecuteError>(),
205203
)?;
206204
pymod.add(
207205
"TransactionClosedError",
208-
py.get_type_bound::<TransactionClosedError>(),
206+
py.get_type::<TransactionClosedError>(),
209207
)?;
210208

211-
pymod.add("BaseCursorError", py.get_type_bound::<BaseCursorError>())?;
212-
pymod.add("CursorStartError", py.get_type_bound::<CursorStartError>())?;
213-
pymod.add("CursorCloseError", py.get_type_bound::<CursorCloseError>())?;
214-
pymod.add("CursorFetchError", py.get_type_bound::<CursorFetchError>())?;
215-
pymod.add(
216-
"CursorClosedError",
217-
py.get_type_bound::<CursorClosedError>(),
218-
)?;
209+
pymod.add("BaseCursorError", py.get_type::<BaseCursorError>())?;
210+
pymod.add("CursorStartError", py.get_type::<CursorStartError>())?;
211+
pymod.add("CursorCloseError", py.get_type::<CursorCloseError>())?;
212+
pymod.add("CursorFetchError", py.get_type::<CursorFetchError>())?;
213+
pymod.add("CursorClosedError", py.get_type::<CursorClosedError>())?;
219214

220215
pymod.add(
221216
"RustToPyValueMappingError",
222-
py.get_type_bound::<RustToPyValueMappingError>(),
217+
py.get_type::<RustToPyValueMappingError>(),
223218
)?;
224219
pymod.add(
225220
"PyToRustValueMappingError",
226-
py.get_type_bound::<PyToRustValueMappingError>(),
221+
py.get_type::<PyToRustValueMappingError>(),
227222
)?;
228223
pymod.add(
229224
"UUIDValueConvertError",
230-
py.get_type_bound::<UUIDValueConvertError>(),
225+
py.get_type::<UUIDValueConvertError>(),
231226
)?;
232227
pymod.add(
233228
"MacAddrConversionError",
234-
py.get_type_bound::<MacAddrConversionError>(),
235-
)?;
236-
pymod.add(
237-
"BaseListenerError",
238-
py.get_type_bound::<BaseListenerError>(),
239-
)?;
240-
pymod.add(
241-
"ListenerStartError",
242-
py.get_type_bound::<ListenerStartError>(),
243-
)?;
244-
pymod.add(
245-
"ListenerClosedError",
246-
py.get_type_bound::<ListenerClosedError>(),
229+
py.get_type::<MacAddrConversionError>(),
247230
)?;
231+
pymod.add("BaseListenerError", py.get_type::<BaseListenerError>())?;
232+
pymod.add("ListenerStartError", py.get_type::<ListenerStartError>())?;
233+
pymod.add("ListenerClosedError", py.get_type::<ListenerClosedError>())?;
248234
pymod.add(
249235
"ListenerCallbackError",
250-
py.get_type_bound::<ListenerCallbackError>(),
236+
py.get_type::<ListenerCallbackError>(),
251237
)?;
252238
Ok(())
253239
}

0 commit comments

Comments
 (0)