Skip to content

Commit

Permalink
feat: Add tracing feature to mnn-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Sep 24, 2024
1 parent 7f70a7e commit ae042ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "Apache-2.0"

[package]
name = "mnn"
version = "0.1.0"
version = "0.2.0"
edition = "2021"
license = { workspace = true }

Expand Down
4 changes: 4 additions & 0 deletions mnn-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ flume = { version = "0.11.0", default-features = false, features = [
] }
mnn = { version = "0.1.0", path = ".." }
oneshot = "0.1.8"
tracing = { version = "0.1", optional = true }

[features]
tracing = ["dep:tracing", "mnn/tracing"]
8 changes: 6 additions & 2 deletions mnn-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ impl SessionHandle {
let (tx, rx) = flume::unbounded();
let handle = builder
.spawn(move || -> Result<()> {
let session = interpreter.create_session(config)?;
let mut session = interpreter.create_session(config)?;
interpreter.update_cache_file(&mut session);
let mut session_runner = SessionRunner {
interpreter,
session,
Expand All @@ -103,7 +104,10 @@ impl SessionHandle {
if let Some(backtrace) = e.downcast_ref::<std::backtrace::Backtrace>() {
err = err.attach_printable(format!("{:?}", backtrace));
};
Err(MNNError::from(err))
let ret = Err(MNNError::from(err));
#[cfg(feature = "tracing")]
tracing::error!("Panic in session thread: {:?}", ret);
ret
});
tx.send(result)
.change_context(ErrorKind::SyncError)
Expand Down

0 comments on commit ae042ac

Please sign in to comment.