Win32::OLE->Getobject hangs??

B

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
 
B

Brian McCauley

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?")
 
B

Ben Morrow

Quoth Brian McCauley said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,999
Latest member
MakersCBDGummiesReview

Latest Threads

Top