Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <20040130130225.61664.qmail@web21101.mail.yahoo.com> Date: Fri, 30 Jan 2004 05:02:25 -0800 (PST) From: Artur de Sousa Rocha Subject: Python error under Cygwin - threading module To: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Hello, Nothing relevant found on Google for this, so I'm asking here. I wrote a short script that launches several threads (parallel download using urllib.urlretrieve in this case). Sometimes when I launch my script under Cygwin, I get strange error messages like: 2 [win] python 1912 Winmain: Cannot register window class Sometimes all of the threads run OK, otherwise after the "correct" ones finish the console stops responding anyway. No problems directly under Windows, and /lib/python2.3/test/test_threading.py works fine too. What is wrong? Here is the script: ---- wp_retr.py ---- #!/usr/bin/env python """Retrieve files from the list, give new names if present in list.""" from __future__ import division import re import urllib import threading import time import sys class Download: def __init__(self, url, name): self.url = url self.name = name self.last_check = 0.0 class DownloadBag: def __init__(self, downloads): self._downloads = [] for url, name in downloads: self._downloads.append(Download(url, name)) def start(self): threads = [] for d in self._downloads: p = self._createProgress(d) thargs = (d.url, d.name, p) th = threading.Thread(target=urllib.urlretrieve, args=thargs) threads.append(th) th.start() return threads def _progress(self, download, blocks, blk_size, total): t = time.time() if t - download.last_check > 5: if total != -1: print "%s -> %s: %2.1f%%" % (download.url, download.name, blocks*blk_size/total*100) else: print "%s -> %s: %d bytes" % (download.url, download.name, blocks*blk_size) download.last_check = t def _createProgress(self, download): def progf(blocks, blk_size, total): self._progress(download, blocks, blk_size, total) return progf if __name__ == "__main__": spcre = re.compile(r"(.*?)\s+(.*)$") slashre = re.compile(r"(?:.*)/(.*?)$") f = file(sys.argv[1]) #"filelist.txt") filelist = [] for line in f: line = line.strip() m = spcre.match(line) if m: url, name = m.groups() else: m = slashre.match(line) if m: url, name = line, m.group(1) else: print "Incorrect line format:\n%s" % line continue filelist.append((url, name)) f.close() db = DownloadBag(filelist) threads = db.start() for t in threads: t.join() ---- and here is an example input file (run "python filelist.py filelist.txt"): ---- filelist.txt ---- http://www.gnu.org/software/bash/manual/bashref.html http://www.gnu.org/software/make/manual/html_mono/make.html ---- --- Jason Tishler wrote: > > FWIW, I cannot reproduce the above problem under: > > > > $ cygcheck -cd cygwin python > > Cygwin Package Information > > Package Version > > cygwin 1.5.5-1 > > python 2.3.2-1 > > > > and > > > > Windows 2000 SP4 > > I "spoke" too soon -- I was able to reproduce the problem after 160 > iterations. Please try the latest snapshot: > > http://cygwin.com/snapshots/ > > and report back whether or not this solves your problem. > > Thanks, > Jason I installed the latest snapshot of cygwin1.dll (cygwin1-20040126.dll.bz2). The problem persists, error messages show about as often as previously. AdSR __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- 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/