You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I run the following code with python3.12 I expect to get back the dataset.
It seems to work but it feels like never ending and many threads returning continuing after the load_mnist() call which is unexpected. Any idea what's going on ? The return [] you see makes the problem go away but return no data. So the load_dataset feels like forking the thread many times and each continuing.
use pyo3::prelude::*;use pyo3::types::IntoPyDict;use pyo3::ffi::c_str;use std::ffi::CString;pubfnload_mnist() -> Vec<(i32,Vec<u8>)>{
pyo3::prepare_freethreaded_python();// Moved herePython::with_gil(|py| {let code = CString::new(r#"from datasets import load_datasetimport pickledef get_mnist(): return [] dataset = load_dataset("mnist", split="train") return [(item["label"], item["image"].tobytes()) for item in dataset]"#).unwrap();let file = CString::new("mnist.py").unwrap();let module_name = CString::new("mnist").unwrap();let module = PyModule::from_code(py,&code,&file,&module_name).unwrap();let result:Vec<(i32,Vec<u8>)> = module
.getattr("get_mnist").unwrap().call0().unwrap().extract().unwrap();
result
})}Can there be a simple workaround like if therad_id is different kill the thread or is there a solution I missed ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
If I run the following code with python3.12 I expect to get back the dataset.
It seems to work but it feels like never ending and many threads returning continuing after the load_mnist() call which is unexpected. Any idea what's going on ? The return [] you see makes the problem go away but return no data. So the load_dataset feels like forking the thread many times and each continuing.
Beta Was this translation helpful? Give feedback.
All reactions