komodo thread problem

2005-02-04 Thread [EMAIL PROTECTED]
Komodo problem with threading:

Hello,

I can't run this program:

def printtime(Max):
 i = 0
 while True:
   time.sleep(1)
   print time.ctime(time.time())
   i+=1
   if i==Max : break
 pass

if __name__ == "__main__":

 thread.start_new_thread(printtime,(2,))

But it runs inside IDLE.

pujo

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


freebsd thread problem

2006-04-24 Thread Dorian Mcfarland
Hi there,
I have installed python(2.4.3) & trac(0.9.4) on freebsd(4.8) from the ports 
collection and I seem to have an underlying problem with the thread module.

Pysqlite is calling 'import thread' which is failing with "no such module" and 
causing it not to load. I thought that 'thread' was one of the core sys.modules 
and when I install python via ports I can see in the makefile that threading is 
turned on.

Salling 'import thread' from the python prompt yields the same result.

I have a 'threading.py' and a 'dummy_thread.py' in my /usr/local/lib/python2.4 
folder and I only have one version of python installed.

Can anyone help me with this? I've googled it and can't find any mention of a 
similar problem anywhere else. I've also been through the trac mailing-list, 
but it doesn't seem like a trac-specific problem.

All/any help greatly appreciated

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


Re: freebsd thread problem

2006-04-24 Thread Ivan Voras
Dorian Mcfarland wrote:
> Hi there,
> I have installed python(2.4.3) & trac(0.9.4) on freebsd(4.8) from the 
> ports collection and I seem to have an underlying problem with the 
> thread module.

> Salling 'import thread' from the python prompt yields the same result.
> 
> I have a 'threading.py' and a 'dummy_thread.py' in my 
> /usr/local/lib/python2.4 folder and I only have one version of python 
> installed.

How did you install python? By default, if built from ports, it should 
pop up a configuration dialog in which one of the options is to enable 
thread support. If you have a bad configuration record, you can do a 
"make config" in /usr/ports/lang/python to re-create it.

(if there's no such option, then maybe using threads with python is 
disabled in 4.x)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: freebsd thread problem

2006-04-24 Thread Dorian Mcfarland
That was the problem. thanks for the clarity - finally working.

> How did you install python? By default, if built from ports, it should 
> pop up a configuration dialog in which one of the options is to enable 
> thread support. If you have a bad configuration record, you can do a 
> "make config" in /usr/ports/lang/python to re-create it.
> 
> (if there's no such option, then maybe using threads with python is 
> disabled in 4.x)
-- 
http://mail.python.org/mailman/listinfo/python-list


os.system() inside a thread problem

2004-12-11 Thread Daniel Bernhardt
Hello,

my thread calls a program with os.system(). 
> os.system("/usr/bin/wine /path/to/ultima/online.exe")
Ultima Online is starting and i can enter commands and navigate through the
game with my keyboard. If I move the mouse over the Ultima Online window
Ultima Online crashes. (the mouse just need to overlap 1 pixel of the egde
of the window. titlebar inlcuded)
> /usr/bin/wine: line 55: 11675 Segmentation fault
Same with os.popen()

If I run os.system() outside the thread everything is working like expected.
Other programs (wine emulated and nativ) work inside and outside the thread.

Can anyone tell me how I can fix this?
Google told me simillar problems were fixed by upgrading to python 2.4. that
is no option for me. 

Thanks,
Daniel


some example code:

from threading import Thread
runuo = StartUO(command)
runuo.start()

class StartUO(Thread):
def __init__(self,command):
Thread.__init__(self)
self.command = command
def run(self):
os.execv(self.command)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system() inside a thread problem

2004-12-11 Thread Fredrik Lundh
Daniel Bernhardt wrote:

> my thread calls a program with os.system().
>> os.system("/usr/bin/wine /path/to/ultima/online.exe")

in the example you included, you use execv.  which one is it?

> Ultima Online is starting and i can enter commands and navigate through the
> game with my keyboard. If I move the mouse over the Ultima Online window
> Ultima Online crashes. (the mouse just need to overlap 1 pixel of the egde
> of the window. titlebar inlcuded)
>> /usr/bin/wine: line 55: 11675 Segmentation fault
> Same with os.popen()
>
> If I run os.system() outside the thread everything is working like expected.
> Other programs (wine emulated and nativ) work inside and outside the thread.
>
> Can anyone tell me how I can fix this?

just curious: do you really have to use a thread?  why not just do

   os.system(command + "&")

 



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


Re: os.system() inside a thread problem

2004-12-11 Thread Daniel Bernhardt
Fredrik Lundh wrote:

> in the example you included, you use execv.  which one is it?

it should be system(). I just played a bit and forgot to change it back. 

> 
> just curious: do you really have to use a thread?  why not just do
> 
>os.system(command + "&")
> 

No, i don't need to use a thread. I just wanted learn something about it and
thought it would be a good start.
I will use "os.system(command + "&")" as you said to solve the problem. 
Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


python's thread problem on Linux platform

2006-04-22 Thread devdoer
I found that  multi-threaded program(io-centralize )  runs very slowly
on linux while the same program   runs very quickly  on windows.If I
change the thread number to one ,the program runs quickly  on linux, in
fact the speed is quicker than the multi-threaded version .
It turns out   that python's multi-thread support on linux has some
problems.Any comments?

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


Re: python's thread problem on Linux platform

2006-04-22 Thread Irmen de Jong
[EMAIL PROTECTED] wrote:
> I found that  multi-threaded program(io-centralize )  runs very slowly
> on linux while the same program   runs very quickly  on windows.If I
> change the thread number to one ,the program runs quickly  on linux, in
> fact the speed is quicker than the multi-threaded version .
> It turns out   that python's multi-thread support on linux has some
> problems.Any comments?
> 

Yes. There is a bug in your code.

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


Re: python's thread problem on Linux platform

2006-04-23 Thread robert
[EMAIL PROTECTED] wrote:

> I found that  multi-threaded program(io-centralize )  runs very slowly
> on linux while the same program   runs very quickly  on windows.If I
> change the thread number to one ,the program runs quickly  on linux, in
> fact the speed is quicker than the multi-threaded version .
> It turns out   that python's multi-thread support on linux has some
> problems.Any comments?
> 

You are probably looping or have other quirks', over-lock-ing ...

Python's thread/threading/Queue stuff is unfortunately Java-ish/ 
OS-mindset and not functional. Thus encourages screwing "ego threads".

Maybe you get things organized frictionless with those 2? :

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491281
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491280

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