I'm writing a Perl program to run on Windows platforms (Win2K and WinXP). whose job is to manage concurrent downloads using libwww-perl (LWP). The basic model is that a manager process checks continuously against a task list (actually a directory containing task files) and launches a sub-process or thread to handle each download. Because the downloads are expected to run concurrently, the manager doesn't wait for the sub-processes to complete.

My first attempt used fork() to launch the sub-processes, and each sub-process would then call exit(0) when complete. However, it appears that exit(0) doesn't release the thread handles: the manager would fork 64 sub-processes successfully, and then die with 'resource temporarily unavailable' on the 65th. Note that this wasn't a case of too many concurrent processes: most of the sub-processes would already have exited, so there were never more than about 20 processes active simultaneously.

I then rewrote the code using threads instead. Each thread was created with new() and then immediately detached using detach(). The manager doesn't need to get a result back from the thread.

This performed even worse: after a random number of thread creations - between about 40 and 60 - Perl would simply exit, and Windows would dump an exception log that indicated thread-related problems. Again, the figure of 40-60 refers not to concurrent threads, but to total threads created.

Has anyone had any experience in writing multi-threaded processes on Windows using libwww-perl? Is it possible to do this stably, or is multi-threading in Windows Perl not yet mature enough? Or, alternatively, am I making some fundamental error in the way I'm going about this?

Thanks in advance for any suggestions,

Angus
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to