Hi people,
I wrote a TCL script and now I am facing problems because I did not specify a timeout condition - I don't know how to do that in TCL!Basically I want that my program continues its execution but ensuring that the timeout limit is never crossed. This is what I tried (among other stuff) but did not work:
-----------------------------------
proc setTimeoutProtection {} {
puts "Inside setTimeoutProtection proc"
global ze
# setting timeout to 1 second
set ze [after 1000 {
puts "timeout condition reach! Leaving program"
puts "end of tcl program due timeout!"
exit 1
}]
puts "going out of setTimeoutProtection proc"
}
#-----------------------
puts "start of tcl program"
setTimeoutProtection
puts "but can do other things"
# setting loop to 5 seconds - which is bigger than timeout value (1 sec)
# this is supposed to trigger the timeout and exit the program
# with return code "1"
for {set i 0} {$i<5} {incr i} {
puts "inside loop that consumes time to trigger timeout condition."
exec sleep 1
}
puts "end of tcl program WITHOUT timeout!"
exit 0
-----------------------------------
Execution output:
start of tcl program
Inside setTimeoutProtection procedure
going out of setTimeoutProtection procedure
but can do other things
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
end of tcl program without timeout!
-----------------------------------
Does anybody knows how to set a timeout in a single thread pure tcl application (without expect).Thanks
BTCMan
I wrote a TCL script and now I am facing problems because I did not specify a timeout condition - I don't know how to do that in TCL!Basically I want that my program continues its execution but ensuring that the timeout limit is never crossed. This is what I tried (among other stuff) but did not work:
-----------------------------------
proc setTimeoutProtection {} {
puts "Inside setTimeoutProtection proc"
global ze
# setting timeout to 1 second
set ze [after 1000 {
puts "timeout condition reach! Leaving program"
puts "end of tcl program due timeout!"
exit 1
}]
puts "going out of setTimeoutProtection proc"
}
#-----------------------
puts "start of tcl program"
setTimeoutProtection
puts "but can do other things"
# setting loop to 5 seconds - which is bigger than timeout value (1 sec)
# this is supposed to trigger the timeout and exit the program
# with return code "1"
for {set i 0} {$i<5} {incr i} {
puts "inside loop that consumes time to trigger timeout condition."
exec sleep 1
}
puts "end of tcl program WITHOUT timeout!"
exit 0
-----------------------------------
Execution output:
start of tcl program
Inside setTimeoutProtection procedure
going out of setTimeoutProtection procedure
but can do other things
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
inside loop that consumes time to trigger timeout condition.
end of tcl program without timeout!
-----------------------------------
Does anybody knows how to set a timeout in a single thread pure tcl application (without expect).Thanks
BTCMan