Jay donnell wrote: > I have a short multi-threaded script that checks web images to make > sure they are still there. I get a segmentation fault everytime I run > it and I can't figure out why. Writing threaded scripts is new to me so > I may be doing something wrong that should be obvious :( >
def run(self): try: self.site = urllib.urlopen(self.url) self.f=open(self.filename, 'w') self.im = Image.open(self.filename) self.size = self.im.size self.flag = 'yes' self.q = "yadda yadda" That's SIX names that don't need to be attributes of the object; they are used _only_ in this method, so they can be local to the method, saving you a whole lot of typing "self." and saving puzzlement & careful scrutiny by those trying to read your code. Back to your real problem: does it work when you set maxThreads to 1? did it work before you added the threading code? what does your debugger tell you about the location of the seg fault? MOST IMPORTANTLY, sort this mess out: self.q = "update item set goodImage = '" + self.flag + "' where productId='" + str(self.id) + "'" print self.q self.cursor.execute(query) ############################### ### "query" is a global variable[YUK!] (see below) which isn't going to do what you want. Looks like you meant "self.q". self.db.close() db = MySQLdb.connect(host="localhost", user="xxx", passwd="xxx", db="xxx") cursor = db.cursor() query = "select * from item order by rand() limit 0, 100" ### Have you looked in your database to see if the script has actually updated item.goodImage? Do you have a test plan? -- http://mail.python.org/mailman/listinfo/python-list