nglenn has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to speed up some conversions from html to wordXML by using threads. I was hoping it would be fairly straightforward to spawn several threads with Microsoft word running from each one, but my code for threads throws errors:
use strict; use threads; use Win32::OLE; my $threadNum = 2; my $directoryLocation = 'C:\Users\nate\Desktop\websites';# opendir(DIR, $directoryLocation); my @files = grep(/\.html$/,readdir(DIR)); closedir(DIR); my @threads; my $counter = 0; for(1..$threadNum){ my @fileSlice = @files[$counter..$counter+$#files/$threadNum]; push @threads, threads->create(\&convertToWord,@fileSlice); $counter += $#files/$threadNum+1; } $_->join for(@threads); sub convertToWord(){ my $Word = Win32::OLE->new('Word.Application', 'Quit'); #convert some stuff to wordXML here, not shown to save space }
Actually, the line about starting Microsoft word isn't needed to make the program fail. The perl interpreter crashes and prints the following:
Free to wrong pool 25f3778 not 213fd8 during global destruction.
When I say crash, I don't mean that the program just exits early, I mean that a window pops up telling me that the Perl Command Line Interpreter has stopped working. Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to use Threads
by Zucan (Beadle) on Jan 09, 2011 at 03:54 UTC | |
|
Re: How to use Threads
by trwww (Priest) on Jan 09, 2011 at 04:38 UTC | |
|
Re: How to use Threads
by roboticus (Chancellor) on Jan 09, 2011 at 13:22 UTC | |
by BrowserUk (Patriarch) on Jan 09, 2011 at 14:15 UTC | |
|
Re: How to use Threads
by Gangabass (Vicar) on Jan 09, 2011 at 15:11 UTC |