in reply to Win32::Process::Info and threads

Looks like very old bug with Win32::OLE (which Win32::Process::Info::WMI "uses") being not thread safe. E.g.: Re: free to wrong pool while global destruction : windows perl environment. And, yes, your example works (i.e. no such error) if Win32::Process::Info is "required" inside a sub instead of "used" globally.

Replies are listed 'Best First'.
Re^2: Win32::Process::Info and threads
by LineStown (Initiate) on Jan 17, 2017 at 15:01 UTC

    I have tried do this:

    use strict; use warnings; use Data::Dumper; use threads; sub include_info { require 'Win32::Process::Info'; } sub test { print "1"; } include_info; my $tid = threads->create(\&test)->join();

    Result: Can't locate Win32::Process::Info in @INC

    But use works. Could you explain my mistake?

        Thank you a lot!

      This Win32::OLE hates Perl's threads too much... Then I'm afraid there's no other option but something like

      use strict; use warnings; use threads; use feature 'say'; sub test { my $s = 'say $_-> { CommandLine } for Win32::Process::Info-> new-> + GetProcInfo'; say qx( $^X -MWin32::Process::Info -E "$s" ); } threads-> create( \&test )-> join;

        Thank you for help