Re: Simple threading example freezes IDLE?

2007-09-29 Thread James Matthews
idle doesn't work well with threads

On 9/27/07, 7stud <[EMAIL PROTECTED]> wrote:
>
> On Sep 26, 5:01 pm, "Sergio Correia" <[EMAIL PROTECTED]> wrote:
> >
> > I'm using IDLE 1.2.1, Python 2.5.1, and Tk 8.4. Does anyone has any
> > idea of why is this happening?
> >
>
> Two mainloops == bad.  IDLE == 1 mainloop.  your program == 1
> mainloop.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://www.goldwatches.com/mens/cufflinks.html
http://www.jewelerslounge.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Simple threading example freezes IDLE?

2007-09-27 Thread 7stud
On Sep 26, 5:01 pm, "Sergio Correia" <[EMAIL PROTECTED]> wrote:
>
> I'm using IDLE 1.2.1, Python 2.5.1, and Tk 8.4. Does anyone has any
> idea of why is this happening?
>

Two mainloops == bad.  IDLE == 1 mainloop.  your program == 1
mainloop.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple threading example freezes IDLE?

2007-09-26 Thread Sergio Correia
I think I have pinpointed the error:

When the -print- command fills the screen, IDLE crashes. That is, if i
have 30 empty lines before I start to push the current screen upwards,
when the last of those lines is used, and its time to push the screen
upwards, IDLE crashes.

I'm using IDLE 1.2.1, Python 2.5.1, and Tk 8.4. Does anyone has any
idea of why is this happening?

Thanks,
Sergio

Example code   --->  http://pastebin.com/f21868e26

import time
import Queue
import threading

class Worker(threading.Thread):

def __init__(self,  inQueue, **kwds):
threading.Thread.__init__(self, **kwds)
self.inQueue = inQueue
self.setDaemon(True)
self.start()

def run(self):
while True:
item = self.inQueue.get()
print item
self.inQueue.task_done()
time.sleep(0.1)

qSymbols = Queue.Queue()
symbols = range(50)
for symbol in sorted(symbols):
qSymbols.put_nowait(symbol)

Worker(qSymbols) # Start thread
qSymbols.join()
print "The End..."




On 9/26/07, Sergio Correia <[EMAIL PROTECTED]> wrote:
> I think the -print- command, as used in IDLE, is not thread-safe. I
> was bitten by an issue like that today, and the problem ended up being
> the -print- command I used.
>
> On the cmd line, it works per-fect-ly.. but IDLE seems to be the culprit.
> A possible answer seems to be to write a wrapper for print that makes
> it thread safe (with the help of a lock.
>
> On 9/19/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > hey all,
> >
> > For my study I'm writing a simple threaded webcrawler and I am trying
> > to do this in python. But somehow, using threads causes IDLE to crash
> > on Windows XP (with the latest python distribution 2.5.1). Even a
> > simple example such as this:
> >
> > import thread, time
> >
> > def doSomething():
> >   print "something"
> >
> > for i in range(2):
> >   thread.start_new(doSomething, ())
> >
> > causes IDLE to freeze when I type it in the interpreter. Using the
> > python command line everything works just fine. Using IDLE on Debian
> > linux also does not cause anything to crash. What am I overlooking?
> >
> > regards, Writser Cleveringa
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple threading example freezes IDLE?

2007-09-26 Thread Sergio Correia
I think the -print- command, as used in IDLE, is not thread-safe. I
was bitten by an issue like that today, and the problem ended up being
the -print- command I used.

On the cmd line, it works per-fect-ly.. but IDLE seems to be the culprit.
A possible answer seems to be to write a wrapper for print that makes
it thread safe (with the help of a lock.

On 9/19/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> hey all,
>
> For my study I'm writing a simple threaded webcrawler and I am trying
> to do this in python. But somehow, using threads causes IDLE to crash
> on Windows XP (with the latest python distribution 2.5.1). Even a
> simple example such as this:
>
> import thread, time
>
> def doSomething():
>   print "something"
>
> for i in range(2):
>   thread.start_new(doSomething, ())
>
> causes IDLE to freeze when I type it in the interpreter. Using the
> python command line everything works just fine. Using IDLE on Debian
> linux also does not cause anything to crash. What am I overlooking?
>
> regards, Writser Cleveringa
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple threading example freezes IDLE?

2007-09-19 Thread writser
hey all,

For my study I'm writing a simple threaded webcrawler and I am trying
to do this in python. But somehow, using threads causes IDLE to crash
on Windows XP (with the latest python distribution 2.5.1). Even a
simple example such as this:

import thread, time

def doSomething():
  print "something"

for i in range(2):
  thread.start_new(doSomething, ())

causes IDLE to freeze when I type it in the interpreter. Using the
python command line everything works just fine. Using IDLE on Debian
linux also does not cause anything to crash. What am I overlooking?

regards, Writser Cleveringa

-- 
http://mail.python.org/mailman/listinfo/python-list