in reply to How to use Threads

nglenn:

Have you considered using separate processes (i.e., fork) instead? If you're not trying to share data between the tasks, then starting a new process for each conversion makes sharing problems like this moot. There's even a nice module Fork::Manager that helps you with the bookkeeping of how many jobs you want to run in parallel, when to submit new ones, etc.

Finally, since you're converting HTML to WordXML, why use Microsoft Word at all? I'm just curious, as I would think that cutting Word out of the loop may speed things up. If I had to do the HTML to WordXML conversion, I think I'd try making a minimal WordXML template, use HTML::Parser to disassemble the HTML document, and spit out the XML. Of course, not having done so, it may be a lot more complicated than I'm guessing. I've done a similar task with Excel once, though, and it was pretty easy. That task took an XML document from a database and whacked it with an XSLT transformation to spit out an HTML document that Excel had no difficulty digesting. (For me, the difficulty was learning enough XSLT to do the job. Actually, I didn't learn it, I just cargo-culted something together.)

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: How to use Threads
by BrowserUk (Patriarch) on Jan 09, 2011 at 14:15 UTC
    (i.e., fork)

    Remember that if the OP is using Word, he his (almost certainly) running on Windows--and on Windows, fork is emulated using threads--so using a forking solution, whether via the built-in fork, or via some module like Parallel::ForkManager, (there doesn't seem to be a Fork::Manager module?), then he would experience exactly the same problems as he is encountering now.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.