Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airectly call signal handler #43

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size difference isn't that big, and for a non-performance-critical repo like this one I think it's ok to let this one slide.

  --> src/error.rs:5:1
   |
5  | / pub enum Error {
6  | |     /// [geojson::Error]
7  | |     #[error(transparent)]
8  | |     GeoJSON(#[from] geojson::Error),
   | |     ------------------------------- the largest variant contains at least 320 bytes
...  |
66 | |     Validation(serde_json::Value),
   | |     ----------------------------- the second-largest variant contains at least 72 bytes
67 | | }
   | |_^ the entire enum is at least 320 bytes
   |

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
Loading