Hello,
while examining the output of a failed testcase I saw a rather odd
message that a timeout occurred after waiting for 30 minutes, although
the timestamps indiciated that the process did only wait for a few seconds.
this was caused by nested timeout blocks:
1. the test runner performed the test in a timeout block, with a short
timout
2. the tested code used a timeout block, too, with a long timeout.
the following snippet shows the problem:
----
| t |
t := Time millisecondClockValue.
[
[ Semaphore new wait ]
valueWithinSeconds: 5
orDo: [
Transcript show: 'inner timout after ',
(Time millisecondClockValue - t ) printString, ' msecs';cr ].
]
valueWithinSeconds: 2
orDo: [
Transcript show: 'outer timout after ',
(Time millisecondClockValue - t ) printString, ' msecs';cr ].
Transcript show: 'Done';cr.
----
output:
inner timout after 2000 msecs
Done
although the outer timeout block timed out.
I've tweaked the timout code to handle nested timeout blocks: The
exception block only handles timeouts triggered by its own delay. Here's
the modified code for VW 7.7:
----
toFinish: aBlock orElse: aTimeoutBlock
| timedProcess timer delay |
timedProcess := Processor activeProcess.
delay := self asDelay.
timer := Process
forBlock: [delay wait.
timedProcess interruptWith: [TimeoutExceeded raiseWith: delay ]]
priority: Processor timingPriority.
^[timer resume.
aBlock ensure: [delay disable.
timer terminate]]
on: TimeoutExceeded
do: [:ex | ex parameter = delay ifTrue: [ aTimeoutBlock value]
ifFalse: [ ex pass ]]
----
output of the example using the patched code:
outer timout after 2000 msecs
Done
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc