Win32::OLE->Getobject hangs??

Win32::OLE->Getobject hangs??

am 13.09.2007 00:15:45 von bubslg

I've got a script that goes through a list of servers and grabs dirve
info from them. The script usually works fine except when it hits a
server that WMI is acting goofy on.

Out of a list of ~250 servers, this call will hang on 2-3 servers.
$WMIServices = Win32::OLE->GetObject("winmgmts:
{impersonationLevel=impersonate}!//$Server/root/cimv2")

Any ideas how to get around this? Is ther a way to force this call to
timeout and move on?

Thanks

Re: Win32::OLE->Getobject hangs??

am 13.09.2007 18:49:04 von nobull67

On Sep 12, 11:15 pm, bubslg wrote:
> I've got a script that goes through a list of servers and grabs dirve
> info from them. The script usually works fine except when it hits a
> server that WMI is acting goofy on.
>
> Out of a list of ~250 servers, this call will hang on 2-3 servers.
> $WMIServices = Win32::OLE->GetObject("winmgmts:
> {impersonationLevel=impersonate}!//$Server/root/cimv2")
>
> Any ideas how to get around this? Is ther a way to force this call to
> timeout and move on?

Have you tried the usual approach? I suspect it won't work in this
case but it's worth a shot.

(See FAQ: "How do I timeout a slow event?")

Re: Win32::OLE->Getobject hangs??

am 14.09.2007 01:28:15 von Ben Morrow

Quoth Brian McCauley :
> On Sep 12, 11:15 pm, bubslg wrote:
> > I've got a script that goes through a list of servers and grabs dirve
> > info from them. The script usually works fine except when it hits a
> > server that WMI is acting goofy on.
> >
> > Out of a list of ~250 servers, this call will hang on 2-3 servers.
> > $WMIServices = Win32::OLE->GetObject("winmgmts:
> > {impersonationLevel=impersonate}!//$Server/root/cimv2")
> >
> > Any ideas how to get around this? Is ther a way to force this call to
> > timeout and move on?
>
> Have you tried the usual approach? I suspect it won't work in this
> case but it's worth a shot.
>
> (See FAQ: "How do I timeout a slow event?")

I thought of mentioning that, but it definitely won't work under any
version of Perl which uses safe signals: even if the signal is
delivered, perl won't check for it until after the XSUB returns.

The correct answer is to write a bit of XS to call
IMoniker::BindToObject (which is the what GetObject ends up calling)
with a IBindCtx specifying a timeout; but that's a job for someone who
knows more about COM than I.

I don't know of any way to break Perl out of an XSUB which has hung. The
only solution I can see (short of fixing Win32::OLE to allow timeouts)
is to perform the GetObject in a new thread, and detach that thread (and
let it fail in its own good time) if you time out. However, I don't know
how well Win32::OLE plays with threads.

Ben