Hi,
I'm using SLIME (2010-11-07) with SBCL(1.0.44.22) on Linux x8664.
The following code should signal an sb-ext:timeout condition but with-timeout isn't functioning on slime-input-stream
with-timeout works with SBCL started from terminal.
(sb-ext:with-timeout 1 (read *standard-input*))
CL-USER> *standard-input* #<SWANK-BACKEND::SLIME-INPUT-STREAM {1002C88D31}>
Cheers,
(sb-ext:with-timeout 1 (read *standard-input*))
with-deadline also doesn't work from inside slime, but generally you should prefer that to with-timeout in production systems.
(with-timeout is not safe due to async unwinds at random points in the code (unless the entire codebase is prepared for that)).
hth,
Hi Attila,
On Wed, Dec 1, 2010 at 8:09 PM, Attila Lendvai attila.lendvai@gmail.com wrote:
(sb-ext:with-timeout 1 (read *standard-input*))
with-deadline also doesn't work from inside slime, but generally you should prefer that to with-timeout in production systems.
Thanks for the advice. Being able to restrict the signal in specific code block is very nice.
(with-timeout is not safe due to async unwinds at random points in the code (unless the entire codebase is prepared for that)).
That makes sense, and I suppose using without-interrupts is unacceptable in the body part.
Since the part I want timeouts are all IO function calls, I think it should be safe. But I think I'd better use with-deadline. :)
* Jianshi Huang [2010-12-01 09:42] writes:
Hi,
I'm using SLIME (2010-11-07) with SBCL(1.0.44.22) on Linux x8664.
The following code should signal an sb-ext:timeout condition but with-timeout isn't functioning on slime-input-stream
with-timeout works with SBCL started from terminal.
(sb-ext:with-timeout 1 (read *standard-input*))
SLIME also uses with-timeout internally. Essentially we have a situation like
(sb-ext:with-timeout 1 (loop (sb-ext:with-timeout 0.2 (handler-case (sleep 10000) (sb-ext:timeout () (print 'timeout) (force-output))))))
The handler doesn't know that the condition was raised by some outer with-timeout.
That's probably just one of many problems of the with-timeout construct and we would like to get rid of it and replace it with a timeout argument to sb-thread:condition-wait. That's not a new issue and adding the timeout argument doesn't sound like rocket science but it doesn't seem to be a priority for the SBCL maintainers. Maybe somebody could hire Nikodemus to finally implement it.
Helmut
Hi Helmut,
On Thu, Dec 2, 2010 at 12:30 AM, Helmut Eller heller@common-lisp.net wrote:
SLIME also uses with-timeout internally. Essentially we have a situation like
(sb-ext:with-timeout 1 (loop (sb-ext:with-timeout 0.2 (handler-case (sleep 10000) (sb-ext:timeout () (print 'timeout) (force-output))))))
The handler doesn't know that the condition was raised by some outer with-timeout.
I see. But why
(handler-case (sb-ext:with-timeout 1 (read *standard-input*)) (sb-ext:timeout (c) c))
or
(handler-case (sb-sys:with-deadline (:seconds 1) (read *standard-input*)) (sb-sys:deadline-timeout (c) c))
also doesn't work. Interestingly, a #SB-SYS:DEADLINE-TIMEOUT is returned in the second case after I slime-interrupted it.
I think I'm still confused.