473,721 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error under Cygwin - threading module

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.urlretri eve 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(Downloa d(url, name))
def start(self):
threads = []
for d in self._downloads :
p = self._createPro gress(d)
thargs = (d.url, d.name, p)
th = threading.Threa d(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_c heck > 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_c heck = 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(lin e)
if m:
url, name = m.groups()
else:
m = slashre.match(l ine)
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(fil elist)
threads = db.start()
for t in threads:
t.join()

----

and here is an example input file (run as python filelist.py
filelist.txt):

---- filelist.txt ----

http://www.gnu.org/software/bash/manual/bashref.html
http://www.gnu.org/software/make/man...mono/make.html

----

TIA,

AdSR
Jul 18 '05 #1
2 2066
AdSR,

On Thu, Jan 22, 2004 at 02:19:31PM -0800, AdSR wrote:
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.urlretri eve 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.
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

What Cygwin, Python, Windows versions are you using?

Have you tried a recent Cygwin snapshot? Some pthread bugs have been
fixed since 1.5.5-1.
No problems directly under Windows,
What does the above mean? Under Win32 Python? Or, under cmd.exe?
What is wrong?


Sorry, I don't know.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6

Jul 18 '05 #2
AdSR,

On Tue, Jan 27, 2004 at 09:46:36AM -0500, Jason Tishler wrote:
On Thu, Jan 22, 2004 at 02:19:31PM -0800, AdSR wrote:
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.


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

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2423
by: Andreou Giannis | last post by:
Allthough it is possible to build modules in Python2.3.3 and distutils with cygwin, by running: setup.py build --compiler=cygwin (after i created the libpython23.a) running: setup.py install afterwards, complains about not building with msvs v.6, since my Python distribution is built with it.
6
3558
by: Steve Holden | last post by:
Does anyone know the workaround for this error, encountered when trying to build PIL 1.1.4 from source under cygwin (Python 2.3.3)? running build_ext building '_imaging' extension gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -IlibImaging -I/usr/include/python2.3 -c encode.c -o
3
1774
by: Olivier Noblanc ATOUSOFT | last post by:
Hello, When i want to import a .py fire from another subdirectory i make import inc/setupxml but that make me an error message.
9
3541
by: Mayer | last post by:
Hello: I'm running python under cygwin and need to find the drive letter. Cygwin has a way of calling my drives by a name relative to the Cygwin directory, so I get things like /home/user rather than /cygdrive/g/cygwin/home/usr, etc. How can I find the letter of the drive, or in the above example, the letter 'g'? My program needs to run on an external media that comes with Cygwin on it. I have no control over what drive is assigned to...
5
4151
by: Gilles DRIDI | last post by:
Does someone has installed wxPython on the Cygwin platform, environment ? Thank you Gilles DRIDI http://cdridi.club.fr
8
1790
by: jcrouse | last post by:
I am using the following code to trap errors in a sub routine: Try Executable code Catch ex As Exception Dim strInputE As String = Application.StartupPath & "\Error.txt" Dim srE As StreamWriter = File.AppendText(strInputE) srE.WriteLine(vbCr) srE.WriteLine(vbCr) srE.WriteLine(DateTime.Now)
2
2189
by: nisimura | last post by:
Hi, I'm trying to use MySQL Python module on Cygwin. Since there is no binary package, I compiled MySQL C client library and Python module (http://sourceforge.net/projects/mysql-python) manually. But when I was trying to load MySQLdb module, following errors happened. Traceback (most recent call last):
0
1555
by: Ling | last post by:
I am using boost.python to wrap C++ function which includes directmusic libraries to simply play the midi, but lots of linkage errors "error LNK2001: unresolved external symbol". I wonder if it is possible to work with DirectX - directmusic libs. Are there any ways to wrap it? *********************compilation errors ************************* msvc.link.dll bin\msvc-7.1\debug\threading-multi\playmusic.pyd bin \msvc-7.1\debu...
3
3083
by: Andy Dingley | last post by:
I'm building Python tools to wrap up access to our Subversion / SVN source control system. It's to run on my desktop (Cygwin under Windows XP) and then later under Redhat. Trying to install the pysvn module I'm running into problems getting it to work under Cygwin. Works fine from a Windows command prompt, with both the svn_cmd.py example and my own Python code. Under Cygwin though I just get import failures. pysvn/__init__.py seems to...
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.