Hi,
I have a question about Python threads vs processes on web servers. I've been writing a cgi script which calls urlopen() at most 30-40 times, and I implemented a separate thread for each urlopen() call so that the total time takes about one second. However, this only works so far for 20 threads or less. Any more threads spawned, and it will give this error:
Exception in thread Thread-2:
Traceback (most recent call last): File
"/usr/lib64/python2.3/threading.py", line 436, in __bootstrap
self.run() File "test.py", line 214, in run current.start() File
"/usr/lib64/python2.3/threading.py", line 410, in start
_start_new_thread(self.__bootstrap, ()) error: can't start new thread
I asked my web hosting service about this, and they said that you can only have "at most 20 concurrent processes" running at the same time. Are threads that are spawned even considered processes? Or is it just because the threads are each taking too much memory?
Furthermore, is there a way to get around this or do some other improvements in my code so I can parse 30-40 urls but keep it down to one or two seconds? Thanks in advance.