Skip to content

Commit

Permalink
Airectly call signal handler (#43)
Browse files Browse the repository at this point in the history
* refactor: directly call signal handler

Not super-imporant I don't think, but it feels better to use `call1` instead of
`run_bound` on some Python code.

* chore: quiet clippy down a bit

* chore: quiet clippy for python too
  • Loading branch information
gadomski authored Oct 18, 2024
1 parent 77a0d38 commit 81af07a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::result_large_err)]

use pyo3::{
create_exception,
exceptions::{PyException, PyIOError, PyValueError},
Expand All @@ -9,6 +11,7 @@ create_exception!(cql2, ValidationError, PyException);
create_exception!(cql2, ParseError, PyException);

/// Crate-specific error enum.
#[allow(clippy::large_enum_variant)]
enum Error {
Cql2(::cql2::Error),
Pythonize(pythonize::PythonizeError),
Expand Down Expand Up @@ -128,15 +131,15 @@ impl From<pythonize::PythonizeError> for Error {
fn main(py: Python<'_>) {
use clap::Parser;

// https://github.com/PyO3/pyo3/issues/3218
py.run_bound(
"import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)",
None,
None,
)
.unwrap();

let signal = py.import_bound("signal").unwrap();
signal
.getattr("signal")
.unwrap()
.call1((
signal.getattr("SIGINT").unwrap(),
signal.getattr("SIG_DFL").unwrap(),
))
.unwrap();
let args: Vec<_> = std::env::args().skip(1).collect();
::cql2_cli::Cli::parse_from(args).run()
}
Expand Down
1 change: 1 addition & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use thiserror::Error;

/// Crate-specific error enum.
#[derive(Debug, Error)]
#[allow(clippy::large_enum_variant)]
pub enum Error {
/// [geojson::Error]
#[error(transparent)]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
unused_qualifications,
unused_results
)]
#![allow(clippy::result_large_err)]

mod error;
mod expr;
Expand Down

0 comments on commit 81af07a

Please sign in to comment.