This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Python 2.5 thread problems


Hi. The following test script works under Linux (I leave it running until 50,000
and then hit Ctrl+C), but it crashes under Cygwin:

#### SCRIPT START ####

#!/usr/bin/python2.5

# This test starts lots of threads, but re-joins with them and calls the python
# garbage collector

import gc
import threading

def worker_func():
    pass

count = 0
while True:
    count += 1
    print "Running thread " + str(count)
    t = threading.Thread(target=worker_func)
    t.setDaemon(True)
    t.start()
    t.join()
    gc.collect()

#### SCRIPT END #####

Here is the output:

#### OUTPUT START ####

./test_threads3.py

[snip]

Running thread 14342
Running thread 14343
Running thread 14344

sem_init: Resource temporarily unavailable
Traceback (most recent call last):
File "./test_threads3.py", line 16, in <module>
t = threading.Thread(target=worker_func)

File "/usr/lib/python2.5/threading.py", line 405, in __init__
self.__block = Condition(Lock())
thread.error: can't allocate lock


#### OUTPUT END ####

It looks like there is a resource leak somewhere. Running thes script again
later it crashed on thread 818.

Disclaimer: I'm not running this under Cygwin myself. I'm writing a
multi-threaded Python app under Linux and forwarding it to a friend who runs
Windows XP SP2 with Cygwin (latest ver as of a few days ago, and with the
Python 2.5.1 Cygwin module). My Python app hits variations of the
above problem and then seg faults.

Also, I think it may be a persistent problem. If you don't restart Cygwin then
Python scripts with lots of thread allocation will crash sooner (ie, if you
manually re-run them in the same Cygwin session each time they crash).

Let me know if you need any further info.

Regards,

David.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]