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

feat: add warning if drop-callback is passed with a tuple #366

Merged
Merged
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
10 changes: 10 additions & 0 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ use crate::{
type RustCallback<T> = zenoh::handlers::Callback<T>;

const CHECK_SIGNALS_INTERVAL: Duration = Duration::from_millis(100);
const DONE_CALLBACK_WARNING: &str = "Passing drop-callback using a tuple \
`(callback, drop-callback)` no more works in 1.0;\n\
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`(callback, drop-callback)` no more works in 1.0;\n\
`(callback, drop-callback)` no longer works in 1.0;\n\

`zenoh.handlers.Callback(callback, drop_callback)` must be used instead.\n\
The tuple form is reserved for passing a handler with`(callback, handler)`.\n\
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The tuple form is reserved for passing a handler with`(callback, handler)`.\n\
The tuple form is reserved for passing a handler with `(callback, handler)`.\n\

If you are already passing a handler but having this warning wrongly displayed, \
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If you are already passing a handler but having this warning wrongly displayed, \
If you are already passing a handler and this warning is still incorrectly displayed, \

you can silent it with:\n\
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
you can silent it with:\n\
you can silence it with:\n\

warnings.filterwarnings(\"ignore\", message=\"Passing drop-callback\")";

fn log_error(py: Python, result: PyResult<PyObject>) {
if let Err(err) = result {
Expand Down Expand Up @@ -436,6 +443,9 @@ where
.ok()
.filter(|(cb, _)| cb.is_callable())
{
if handler.bind(py).is_callable() {
import!(py, warnings.warn).call1((DONE_CALLBACK_WARNING,))?;
}
(python_callback(&cb)?, HandlerImpl::Python(handler))
} else {
return Err(PyValueError::new_err(format!(
Expand Down
Loading