freenode/#lisp - IRC Chatlog
Search
17:05:47
tryingoutlisp
I get an unbound-variable error. Let me pastebin an example so I can show you.
17:45:42
jmercouris
so, I'm running (bt:make-thread (lambda () (uiop:run-program "xyz"))), how can I know when xyz has started?
17:46:09
jmercouris
mind you, xyz is a long-running process, and will continue to run, it's not like I'm looking for an exit code or anything
17:52:29
flip214
or you look at the child process' CPU usage - and after 1 sec or so you know it's "up" (and not crashed yet)
17:52:54
flip214
or you can use ptrace and see when it has reached some important point (listening socket open, etc.)
17:54:24
|3b|
but yeah, if you need to interact with it, probably better to just have it tell you when it is ready if possible
17:54:50
flip214
jmercouris: is there some external effect you can watch for? like a http server which you can ask for /status or so?
17:55:06
flip214
jmercouris: signals are not that easy to handle correctly; even less so in multi-threaded programs.
17:59:57
jmercouris
so I'm not sure how to loop on retrying the command until I don't get a connection-refused-error
18:06:11
fortitude
jmercouris: you might want to use that handler case in a function that returns T or NIL based on whether the connect succeeded
18:08:25
fortitude
jmercouris: if it helps, handler-case is known as try/catch in other languages, so if you've ever used that before, you can do the same sort of things
18:09:04
jmercouris
(make-window) in the above code is making the XML-RPC call which depends on the other program to be running
18:10:29
jmercouris
dlowe: ah, so you set the loop expression it is looking out for within the cases
18:18:31
|3b|
ACTION tends to just loop on 2nd value of ignore-errors when i'm expecting lots of errors :p
18:23:04
fortitude
jmercouris: your handler-case form doesn't have any error clauses, and your handler-bind form doesn't have a body (they're two separate ways of handling errors)
18:24:13
fortitude
what you want is (handler-case <your thing> ((sb-bsd-sockets:connection-refused-error () <your handling code>)))
18:26:20
fortitude
jmercouris: if it makes you feel better, I can never remember which syntax goes with which form either
18:31:07
jmercouris
you know, I often look at the hyperspec, and I'm still not that good at understanding it
18:31:49
fortitude
jmercouris: the grammar notation can be a little tricky sometimes, but it helps if you pair it with the examples
18:37:48
malice
However, there is an effort by phoe called CLUS, short for COMMON LISP ULTRASPEC, which tries to provide a better hyperspec: http://phoe.tymoon.eu/clus/doku.php?id=cl:macros:handler-case
18:38:08
jmercouris
I don't want to disparage the ultraspec project, but it is on permanent hiatus afaik
18:39:06
malice
dlowe: On more than one occasion I found that examples weren't clear enough or didn't showcase what I wanted to know (and I do not think I was looking for anything extraordinary).
20:15:42
veddox
Hey everyone, I have a bit of a problem with usocket and I'm wondering whether somebody here might have the time to help...
20:16:45
veddox
Basically, I am working on a client-server game. The relevant code is here: https://gist.github.com/veddox/d0df0d6ea685a348d5674c30b2cdfe6d
20:18:08
veddox
I can create the server (`run-server`), and connect to it (`connect-server`), and `handle-connection` will confirm a connection has been made
20:18:34
veddox
However, when I then call `query-server`, the string I send to the server socket won't arrive
20:19:36
veddox
It appears the stream is not being flushed, but I do call `finish-output` (line 102), so I'm a bit baffled.
20:20:06
dlowe
(format servstr request) request should probably be a string or you shouldn't use FORMAT
20:20:48
veddox
It is one. For test purposes I call it as (query-server "ACK") - which ought to return "ACK ACK"
20:21:15
sjl_
dlowe is saying that if your request happens to contain format directives, it'll do surprising things
20:22:13
sjl_
How do you know the string you're sending doesn't arrive? I see where you log the connection, but not where you log the strings you receive
20:23:54
sjl_
I've had this bite me before -- everything's actually working, but my final log line was stuck in a buffer waiting to be flushed
20:24:18
veddox
logging is a macro: (defmacro logging (str &rest format-args) `(write-to-file (format NIL ,str ,@format-args) *logfile* T))
20:26:43
veddox
`write-to-file` takes a string or a list of strings and writes them all to file (calling `open` directly), the closes the file connection
20:30:52
dlowe
veddox: right. if you know the packet is sent then you know a lot more about where the problem might be
20:31:39
veddox
@sjl_ Yes I do. I get "received a connection", "sending request" and "waiting for server response"
20:34:33
sjl_
be careful wil parsing user-supplied input into symbols in a package -- since they don't get GC'ed you can exhaust the server's memory by just sending tons of symbols
20:45:46
veddox
Thank you very much for your help! I've been chasing that bug for a couple of days now :-)