-
Notifications
You must be signed in to change notification settings - Fork 34
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
Cannot use two irust_repl
s at the same time.
#114
Comments
Yes your guess is right it uses a hardcoded cargo project path, I can look later at making this configurable |
I can't reproduce the issue on linux , theoretically it shouldn't error , because the state is kept in memory and each time eval runs it will copy that state from memory to disk The only problem I can see is that if the code runs in multiple threads at the same time, there is a risk of things getting messed up (like one repl accessing another repl values) I think I should fix this issue by giving each repl its unique project, but I'm not 100 % sure it will fix your issue, if you have a minimal code that code can reproduce the issue that would be great This is what I'm using to test the multi thread issue for example #[test]
fn two_repls_at_the_same_time() {
let mut repl1 = Repl::default();
let mut repl2 = Repl::default();
repl1.insert("let a = 4;");
repl2.insert("let a = 5;");
let a1_thread =
std::thread::spawn(move || repl1.eval("a").unwrap().output.parse::<u8>().unwrap());
let a2_thread =
std::thread::spawn(move || repl2.eval("a").unwrap().output.parse::<u8>().unwrap());
assert_eq!(a1_thread.join().unwrap() + a2_thread.join().unwrap(), 9) // this might fail it might equal to 10
} |
Can you test this pr #115 |
I just test the new
I'm using a lot of IJulia, which is a repl for Julia. It is amazing but with a imperfection, by which the users suffer a lot: it takes too long for the first running. That problem also lies in evcxr , in a more severe way. I thought irust may solved this problem. Being grateful for your work, I thought in my personal view if irust have a full support for jupyter kernel, it will be a blazing edge for rust, and will contribute a lot to make rust more popular. |
Nice, glad it worked, the repl structs currently doesn't clean the created paths , though I exposed already a function to do that and irust uses it, I think I'll just go ahead and make it automatic by implementing it on drop (so it works as you described) I'll try to make some time and evaluate jupyter again, did you try https://github.com/sigmaSd/IRust/tree/master/crates/irust_repl#jupyter-kernel btw ? does it do what you expect ? |
Yes, I tried https://github.com/sigmaSd/IRust/tree/master/crates/irust_repl#jupyter-kernel several times before on Windows, it didn't work. When I open jupyter and click the run button, it run down immediately and no output shows, the terminal also says the kernel is terminating. I guess there may be errors on the output part. |
I tried the kernel in linux and it seems to work, did you follow the steps ? can you see the kernel with jupyter kernelspec list, also is the I'll have to find a windows machine to test otherwise |
I just tried again, |
That error mean that your path is not set up correctly, you can try changing 're' here https://github.com/sigmaSd/IRust/blob/master/crates/irust_repl/irustkernel/irust.py#L48 to the absolute path of the binary (C:://...path..here../re) |
I just tried that, and then there is a new type of error: |
Can you add a |
Also can we continue this conversation here instead #108 |
Maybe you need to run |
also if that doesn't work I'll need a print here https://github.com/sigmaSd/IRust/blob/master/crates/irust_repl/irustkernel/irust.py#L20 , if there is no output that means jupyter is not sending any code to the kernel |
I mean you should add print and see the console, its for debugging, I want to see if the code gets printed |
The warning is probably harmless since it does execute, it's weird that do_execute doesn't pass code, if you want to debug more you can try the echo kernel from here https://jupyter-protocol.readthedocs.io/en/latest/wrapperkernels.html |
Btw for the path issue I remembered in windows you might need cmd prefix so instead of run(["re") you can try run(["cmd","/c", "re" |
Ok so the cmd prefix does fix the first issue |
you seem to have reamoved Code and deps variable, It should be run(cmd,/c,re,deps,code) |
Yes thats probably normal, jupyer is not printing it , for debugging we should print to stderr instead so it shows up in the console Can you try btw run("cmd","/c","re",deps,code) instead of the absolute path of re , does that still work ? IF you have some feedback /suggestions / new issues on this kernel feel free to add it here #108 |
Now everything works fine, and I put the comments to #108 . |
I have two object
irust_repl
:irust_repl1
andirust_repl2
. When I callirust_repl1.eval(some_code)
andirust_repl2.eval(some_code)
at the same time, the latter has alink.exe
error. I thought it maybe because that no matter how manyirust_repl
I have, they all is based on the same temp file, and so manupulating the samemain.rs
at the same time.So, if I need run the
irust_repl
s at the same time, what should I do?The text was updated successfully, but these errors were encountered: