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

G

gganesh

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 .
 
M

MRAB

gganesh said:
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):
^^^
Should be __init__.
 
G

gganesh

gganesh said:
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
# create a queue class
q=Queue.Queue()
#Thread class
class MyThread(threading.Thread):
   # define __int__ method acting like constructor
   def __int__(self,q):

               ^^^
               Should be __init__.
           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 .

hi
It did work that way

File "queue.py", line 15
threading.Thread__init__.(self)
^
SyntaxError: invalid syntax
 
D

Diez B. Roggisch

gganesh said:
gganesh said:
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
# create a queue class
q=Queue.Queue()
#Thread class
class MyThread(threading.Thread):
# define __int__ method acting like constructor
def __int__(self,q):

^^^
Should be __init__.
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 .

hi
It did work that way

File "queue.py", line 15
threading.Thread__init__.(self)
^
SyntaxError: invalid syntax

Because you messed up the .

threading.THread.__init__(self)

Please spend at least a couple of hours with the tutorial.

Diez
 
M

maxim

hi
It did work that way

File "queue.py", line 15
    threading.Thread__init__.(self)
                             ^
SyntaxError: invalid syntax

You've wrote right first time "threading.Thread.__init__(slef)", but
misprinted in your code "def _int_(self,q)" instead of "def __init__
(self,q)".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,985
Messages
2,570,202
Members
46,777
Latest member
JosefinaAc

Latest Threads

Top