-
Notifications
You must be signed in to change notification settings - Fork 32
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
Error not signaled when cannot run Python process #25
Comments
Thanks! Yes, the error message could definitely be better. I guess it's also possible that the python process may crash or hang at some later time so the library should handle that better. Perhaps just handling end-of-file conditions in a better way, with a more useful error message? |
Yes, now I see that these CL standard As to the error message, I imagine it would suggest checking configuration (like that global variable) if you get the error immediately, and ??? otherwise. Many things can mess up a process. (Edit: and maybe do it as a condition rethrow to let the client handle it in some custom way). One thing I was also thinking of is giving a "debug" option to print the Python/child process output directly in Lisp REPL. (Potentially it could also alert people that they use different version of Python than they thought etc.). Don't know if it would make sense with the method of communicating with the process that you are using. |
One way to better the error could be to wrap the body of Also, a simple way to reproduce the error (so as to be able to write test code) could be
I am not sure I quite get that - are you referring to the following code producing output after it completes - or something else: (python-exec "
for i in range(10):
import time
time.sleep(1)
print(i)")
May be, we can print the |
Yes, I would use As to the test case, ending process from inside Python (as you propose) is probably the same as failing to run Python at all, although there could be some edge cases. I don't know. My thinking was to try to run some bogus
Yes, to see Python prints as Lisp prints (although doesn't this work by default?). I thought that people could see "python: No such file or directory" from Bash when they don't have
It would be nice, at least as an option that one can turn off. (I'm assuming you meant "when starting the Python process", because from my understanding loading the package alone doesn't start it) |
One possible way is implemented using multithreading in py4cl2 - however, this breaks code if someone has used something like - [However, it seems like you mean something else when you mention the next things in reference to Yup, the python process doesn't start wen package is loaded - though it would be trivial (and non-breaking?) to make it start during package load. |
I think the current state (deferring the start of the python process) is better in that regard, for example allowing for setting some options before it is started. As to "python: No such file or directory", I mean just what would happen in the terminal if you would enter |
I, finally, have it implemented (reliably) using macros and thread synchronization in the form of |
For the complete fix for EOF error, my plan is to signal a "EOF reached while reading from python's output stream" This will be coupled by a dynamic variable, which if bound or set to In callpython.lisp, an additional macro Edit: Tried a more minimal approach of catching the error in |
I'm on Fedora 30 with SBCL 1.4.14-2.fc30. I have
python3
, but nopython
(Python 2). Initially I couldn't import any modules because of crypticend of file on #<SB-SYS:FD-STREAM for "descriptor 23" {1003824B03}> [Condition of type END-OF-FILE]
errors, but by digging through the code I discovered I'm supposed to setfpy4cl:*python-command*
topython3
. Now it works great.I also see that
python-start-if-not-alive
should've signalled a better error in my case. I think the problem is because the(python-alive-p)
check happens when bash, or whatever, is still busy failing. This works:Sadly I don't know how to fix it in a sane way.
I also think the error here could suggest checking your
py4cl:*python-command*
for a probable cause.The text was updated successfully, but these errors were encountered: