dmolina / DaemonMode.jl

Client-Daemon workflow to run faster scripts in Julia
MIT License
272 stars 16 forks source link

exit() exits the server #61

Open tecosaur opened 1 year ago

tecosaur commented 1 year ago

Hello again,

I put exit(2) in a script, and noticed that running it with DaemonMode seemed to cause the server to exit, not the client. Since I feel scripts may reasonably use exit codes to signal different types of errors, this behaviour seems rather undesirable to me.

dmolina commented 1 year ago

Dear @tecosaur,

It is strange for me, because DaemonMode redefine the exit function to avoid close by using it. I have just checked with the simple:

println("hola")
exit(2)
println("adios")

And the Daemon does not finish, it is the client program that it closes. Could you give me a simple example in which it happens? Thank you.

tecosaur commented 1 year ago

The file I ran literally just had exit(2) in it, executed with ~/Downloads/jclient_x64_linux /tmp/test.jl

tecosaur commented 1 year ago

On a side note, having looked at this package a bit more, I'm interested in exploring a slightly different approach. This weekend I'll see if I can put together a little proof of concept. If it turns out well I might call it something like "DaemonPuppeteer.jl" and make it public.

dmolina commented 1 year ago

It is strange, because I use DaemonMode everyday, and exit() does not exit in my case.

my test.jl: println("hola") exit(2) println("adios")

And it is working nicely, could you give me your julia and package version?

About a different approach, I would like to see that, advise me when it is accesible.

tecosaur commented 1 year ago

Could you give me your julia and package version?

Sure, I'm using Julia 1.8.4 and DaemonMode 0.1.2.

Here's what I'm seeing in raw form:

julia> using DaemonMode

julia> serve()
16:10:08 ❯ echo $?
2
16:08:52 ❯ cat /tmp/test.jl
exit(2)
16:09:06 ❯ ~/Downloads/jclient_x64_linux /tmp/test.jl
16:10:04 ❯ echo $?
1

About a different approach, I would like to see that, advise me when it is accessible.

Will do :slightly_smiling_face:. I initially started thinking about making PRs to DaemonMode, but then realised that what I've ended up thinking of is really a different beast entirely (looking at how DaemonMode has been implemented).

dmolina commented 1 year ago

Ok, thank you. My DaemonMode version is 0.1.10. Try update it, maybe your Julia version could be updated.

Any PR is always welcome. However, if you have a completely different approach, try it, also. This is a hack that I implemented a weekend mainly for me, and it is sucessfully working for me now (I work in algorithm with a lot of CPU processing, and while I used Python for prototype new algorithms, it was very time consuming to improve the code, measuring the bottleneck and using C/C++ for the most critical parts, now I use everyday Julia and I am very happy with that). However, maybe a different approach could be better for everybody (even me ;-) ). Actually, I am not sure how to solve problems in the output. Only one suggestion, if you are open to use sockets, it allows you to use a binary client. I use https://github.com/dmolina/juliaclient_nim, and I am very happy with that, for small programs it is even faster than Python because it does not have to wait for the interpreter :-). Another good possibility (if the security is implemented) is to be able to run in a computer locally, and not taking to install julia in the computer client. I was expecting to implement that part, but I never have enough time.

tecosaur commented 1 year ago

Actually, I am not sure how to solve problems in the output. Only one suggestion, if you are open to use sockets, it allows you to use a binary client. I use https://github.com/dmolina/juliaclient_nim, and I am very happy with that, for small programs it is even faster than Python because it does not have to wait for the interpreter :-).

Thanks for the tip, I've actually already done this and my client is written in Zig :)

If you're interested in chatting more on this, do contact me on Discord (tecosaur#2786) or Matrix (@tecosaur:matrix.org).

tecosaur commented 1 year ago

FYI I now have a repo: https://github.com/tecosaur/DaemonConductor.jl

dmolina commented 1 year ago

Thank you for the information. I tried to install with Julia 1.8, and it gives me:

ERROR: Unsatisfiable requirements detected for package XDG [cf316f05]: XDG [cf316f05] log: ├─XDG [cf316f05] has no known versions! └─restricted to versions * by DaemonConductor [17525775] — no versions left └─DaemonConductor [17525775] log: ├─possible versions are: 0.1.0 or uninstalled └─DaemonConductor [17525775] is fixed to version 0.1.0

However, I understand it is a working repo.

tecosaur commented 1 year ago

Yea, I'm yet to register https://github.com/tecosaur/XDG.jl (having last-minute "should this be the name" indecision). If you dev XDG.jl and then manually clone DaemonConducter (get HEAD not 0.1), then it should work :slightly_smiling_face:

tecosaur commented 1 year ago

(pst. @dmolina it should be easier to try now)

tecosaur commented 1 month ago

I was reminded of this recently, so for fun here's another light poke in case you're still interested in checking things out :slightly_smiling_face: