For Programmers: Free Programming Magazines  


Home > Archive > Tcl > January 2008 > Time out operation









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Time out operation
Chendu

2008-01-29, 4:56 am

Case : I have to retrieve data from different servers.

I have to fetch the data from different servers, I am able to do this
in sequence.
Now problem is suppose one server is down, the script is hanging.
I wanted to include a time out option where in it tries for period of
time. if its timed out, It should continue and go to retrieve the data
from other servers.

How can i do this in TCL. There is not time out option.
time command is there, i dont think i can make use of it.
Can some one give suggestion for this.

Thanks
Senthilvelu

Derek Fountain

2008-01-29, 9:00 am

Chendu wrote:
> Case : I have to retrieve data from different servers.
>
> I have to fetch the data from different servers, I am able to do this
> in sequence.
> Now problem is suppose one server is down, the script is hanging.
> I wanted to include a time out option where in it tries for period of
> time. if its timed out, It should continue and go to retrieve the data
> from other servers.
>
> How can i do this in TCL. There is not time out option.
> time command is there, i dont think i can make use of it.
> Can some one give suggestion for this.


How are you getting the data from the servers? Using Tcl or an external
process of some sort? If it's Tcl you can directly use 'after' to
interrupt the data collection and bail out of it. If you're using a
separate process you'll need to set it running in the background and
then use 'after' to kill it in whatever way is suitable given what
you're doing.

It's hard to be more specific given so little information.
Pascal

2008-01-29, 7:42 pm

Chendu a écrit :
> Case : I have to retrieve data from different servers.
>
> I have to fetch the data from different servers, I am able to do this
> in sequence.
> Now problem is suppose one server is down, the script is hanging.
> I wanted to include a time out option where in it tries for period of
> time. if its timed out, It should continue and go to retrieve the data
> from other servers.
>
> How can i do this in TCL. There is not time out option.
> time command is there, i dont think i can make use of it.
> Can some one give suggestion for this.
>
> Thanks
> Senthilvelu
>


usage : vwaitTimed ::myvar 3000 (will timeout after 3 sec), and I
suppose ::mywar is set by server #n

########################################
########################################

# vwait but will timeout after a delay. Var must be fully qualified (::)
########################################
########################################

proc vwaitTimed { var {delay 0} {warn "warnuser"} } {

proc trigger {var warn} {
if {$warn == "warnuser"} {
tk_messageBox -type ok -icon error -parent . -title "Protocol
error" -message "vwait timeout for $var"
}
set $var 1
}

if { $delay != 0 } {
set timerId [after $delay "trigger $var $warn"]
}

vwait $var

if [info exists timerId] { after cancel $timerId }

}

Pascal
Chendu

2008-01-30, 7:46 pm

On Jan 29, 11:16=A0pm, Pascal <pas...@nospam.fr> wrote:
> Chendu a =E9crit :
>
>
>
>
>
>
>
>
>
> usage : vwaitTimed ::myvar 3000 (will timeout after 3 sec), and I
> suppose ::mywar is set by server #n
>
> ########################################
##################################=

#=AD#####
> # vwait but will timeout after a delay. Var must be fully qualified (::)
> ########################################
##################################=

#=AD#####
> proc vwaitTimed { var {delay 0} {warn "warnuser"} } {
>
> =A0 =A0proc trigger {var warn} {
> =A0 =A0 =A0if {$warn =3D=3D "warnuser"} {
> =A0 =A0 =A0 =A0tk_messageBox -type ok -icon error -parent . -title "Protoc=

ol
> error" -message "vwait timeout for $var"
> =A0 =A0 =A0}
> =A0 =A0 =A0set $var 1
> =A0 =A0}
>
> =A0 =A0if { $delay !=3D 0 } {
> =A0 =A0 =A0set timerId [after $delay "trigger $var $warn"]
> =A0 =A0}
>
> =A0 =A0vwait $var
>
> =A0 =A0if [info exists timerId] { after cancel $timerId }
>
> }
>
> Pascal- Hide quoted text -
>
> - Show quoted text -


I am using a external command to get the data from the server.
Chendu

2008-01-30, 7:46 pm

On Jan 30, 6:47=A0pm, Chendu <pjsent...@gmail.com> wrote:
> On Jan 29, 11:16=A0pm, Pascal <pas...@nospam.fr> wrote:
>
>
>
>
>
>
>
[color=darkred]
>
>
>
>
###=AD=AD#####[color=darkred]
[color=darkred]
###=AD=AD#####[color=darkred]
>
ocol[color=darkred]
>
>
>
>
>
>
>
> I am using a external command to get the data from the server.- Hide quote=

d text -
>
> - Show quoted text -



variable data // this is global
set ser { list of server}

foreach serverName $ser {
set data [getDatafrom $serverName]
}

Whats happening is when the server is down whole script is hanging. It
is now trying to get data from other servers

Now, how can i use vWaitTimed procedure . should the getDatafrom
should be passed as argument in place on var.
what the vwait does.

Senthil
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com