fix Python decoder
This commit is contained in:
parent
c5df5eb6d3
commit
8d16b8159e
|
@ -84,6 +84,10 @@ pub async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> AddedDecodersCount
|
||||||
|
|
||||||
let mut added_decoders_count = 0;
|
let mut added_decoders_count = 0;
|
||||||
|
|
||||||
|
// @TODO (?) New thread to prevent "Cannot start a runtime from within a runtime."
|
||||||
|
// when a call to a component fails / panics
|
||||||
|
// std::thread::spawn(move || {
|
||||||
|
// futures::executor::block_on(async move {
|
||||||
for decoder_path in decoder_paths {
|
for decoder_path in decoder_paths {
|
||||||
if let Err(error) = add_decoder(&decoder_path).await {
|
if let Err(error) = add_decoder(&decoder_path).await {
|
||||||
eprintln!("add_decoders error: {error:?}");
|
eprintln!("add_decoders error: {error:?}");
|
||||||
|
@ -91,6 +95,8 @@ pub async fn add_decoders(decoder_paths: Vec<DecoderPath>) -> AddedDecodersCount
|
||||||
added_decoders_count += 1;
|
added_decoders_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// })
|
||||||
|
// }).join().unwrap();
|
||||||
|
|
||||||
added_decoders_count
|
added_decoders_count
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,22 +91,22 @@ async fn load_signal_and_get_timeline(
|
||||||
// "Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks."
|
// "Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks."
|
||||||
// @TODO Workaround? Is it a problem only for non-Rust components? Is it needed only when there is a problem in the component (e.g. "`Err` value: wasm trap: cannot enter component instance"?)
|
// @TODO Workaround? Is it a problem only for non-Rust components? Is it needed only when there is a problem in the component (e.g. "`Err` value: wasm trap: cannot enter component instance"?)
|
||||||
// let value = std::thread::spawn(move || {
|
// let value = std::thread::spawn(move || {
|
||||||
// futures::executor::block_on(async move {
|
// futures::executor::block_on(async move {
|
||||||
let decoders = component_manager::DECODERS.read().await;
|
let decoders = component_manager::DECODERS.read().await;
|
||||||
let mut store_lock = component_manager::STORE.lock().await;
|
let mut store_lock = component_manager::STORE.lock().await;
|
||||||
let mut store = store_lock.as_context_mut();
|
let mut store = store_lock.as_context_mut();
|
||||||
|
|
||||||
for decoder in decoders.iter() {
|
for decoder in decoders.iter() {
|
||||||
value = decoder
|
value = decoder
|
||||||
.component_decoder_decoder()
|
.component_decoder_decoder()
|
||||||
.call_format_signal_value(&mut store, &value)
|
.call_format_signal_value(&mut store, &value)
|
||||||
// @TODO Resolve panic when running non-Rust components:
|
// @TODO Resolve panic when running non-Rust components:
|
||||||
// `Err` value: wasm trap: cannot enter component instance
|
// `Err` value: wasm trap: cannot enter component instance
|
||||||
// https://github.com/bytecodealliance/wasmtime/issues/8670 ?
|
// https://github.com/bytecodealliance/wasmtime/issues/8670 ?
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
// value
|
// value
|
||||||
// })
|
// })
|
||||||
// }).join().unwrap();
|
// }).join().unwrap();
|
||||||
value
|
value
|
||||||
})
|
})
|
||||||
|
|
Binary file not shown.
|
@ -5,7 +5,8 @@ name = "Python Test Decoder"
|
||||||
|
|
||||||
class Decoder(exports.Decoder):
|
class Decoder(exports.Decoder):
|
||||||
def init(self) -> None:
|
def init(self) -> None:
|
||||||
# @TODO it panics for some reasons
|
# @TODO it panics with error `7: 0xae8683 - libcomponentize_py_runtime.so!componentize-py#Dispatch`
|
||||||
|
# - see https://github.com/bytecodealliance/componentize-py/blob/e20d9e6706ff1421cd8001449acb51eb9c87d0c6/runtime/src/lib.rs#L404
|
||||||
# host.log(f"{name} initialized")
|
# host.log(f"{name} initialized")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -13,4 +14,4 @@ class Decoder(exports.Decoder):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def format_signal_value(self, value: str) -> str:
|
def format_signal_value(self, value: str) -> str:
|
||||||
return str + "!"
|
return value + "!"
|
||||||
|
|
Loading…
Reference in a new issue