delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/03/23/08:32:55

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <18c1e6480803230632n65798fdcufcac320079b2475a@mail.gmail.com>
Date: Sun, 23 Mar 2008 15:32:18 +0200
From: David <wizzardx AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Python 2.5 thread problems
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019