Win32::OLE->Getobject hangs??

Discussion in 'Perl Misc' started by bubslg, Sep 12, 2007.

  1. bubslg

    bubslg Guest

    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
    bubslg, Sep 12, 2007
    #1
    1. Advertising

  2. 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?")
    Brian McCauley, Sep 13, 2007
    #2
    1. Advertising

  3. bubslg

    Ben Morrow Guest

    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
    Ben Morrow, Sep 14, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick.O.Ige

    Ole ole

    Patrick.O.Ige, Jul 16, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    490
    Patrick.O.Ige
    Jul 16, 2006
  2. Drew Pihera
    Replies:
    0
    Views:
    640
    Drew Pihera
    Feb 4, 2004
  3. Lance Hoffmeyer
    Replies:
    0
    Views:
    238
    Lance Hoffmeyer
    Nov 17, 2003
  4. Goh, Yong Kwang

    Win32::OLE->GetObject doesn't work on WinXP?

    Goh, Yong Kwang, Jun 17, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    293
    Thomas Kratz
    Jun 17, 2004
  5. TomW
    Replies:
    2
    Views:
    140
Loading...

Share This Page