[Tutor] Problem with threads

David Cohen dacohen at gmail.com
Mon Feb 27 00:42:13 CET 2006


Hi,

Here is the code attached. It is a simple test program that open a gtk
window and connect to a server (might be an irc or telnet server).
When the button "Connect" is clicked, the thread (should) starts and
read what is coming from the server. But it never happens... just when
I click on the "Disconnect" button and the join() function is called.
Did you get any problem like that?

BR,

David

On 2/25/06, Kent Johnson <kent37 at tds.net> wrote:
> David Cohen wrote:
> > Hi all,
> >
> > I have a problem trying to use thread on python.
> > I import the threading module and execute this:
> >
> > def func_thread():
> >     something...
> >
> > new_thread = threading.Thread(target = func_thread)
> > new_thread.start()
> >
> > But the thread never really starts, just when I call the
> > new_thread.join() method.
> > Does anybody could help me?
>
> More code would help. What you have shown looks fine. What does
> func_thread() do? How do you know it isn't doing it? Here is a very
> simple, working example based on your code:
>
> import threading, time
>
> def func_thread():
>      while True:
>          print 'threading'
>          time.sleep(1)
>
> new_thread = threading.Thread(target = func_thread)
> new_thread.start()
>
> print "main thread going away now"
>
> Kent
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_socket.py
Type: text/x-python
Size: 3205 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20060226/53641114/attachment.py 


More information about the Tutor mailing list