AssertionError - help me to solve this in a programme with Queue

gganesh ganesh.gbg at gmail.com
Tue May 12 09:21:10 EDT 2009


Hi all,
I'm just learning python ,the code below is found in one of the
sites ,it produces an error like
Traceback (most recent call last):
  File "queue.py", line 34, in <module>
    main()
  File "queue.py", line 28, in main
    t=MyThread(q)
  File "/usr/lib/python2.5/threading.py", line 398, in __init__
    assert group is None, "group argument must be None for now"
AssertionError: group argument must be None for now

can any one help me to find the reason

the code I wrote is


hosts =["http://yahoo.com", "http://google.com"]

# create a queue class
q=Queue.Queue()

#Thread class
class MyThread(threading.Thread):
	# define __int__ method acting like constructor
	def __int__(self,q):
		threading.Thread.__init__(self)
		self.q=q
	def run(self):
		h=self.q.get()
		opens=urllib2.urlopen(h)
		print opens.read(100)

		# signal the queue to say job is done
		self.q.task_done()
a=time.time()
def main():
	# create a pool of thread
	for i in range(5):
		t=MyThread(q)
		t.setDaemon(True)
		t.start()
	for h in hosts:
		queue.put(h)
	q.join()
main()
print "Time elasped : %s "%(time.time()-a)


The problem may be silly ,hence I'm every new to python i need your
guidance .





More information about the Python-list mailing list