Problem with Threads

2012-12-19 Thread Kwnstantinos Euaggelidis
I have this code for Prime Numbers and i want to do it with Threads.. Any idea.?? # prime numbers are only divisible by unity and themselves # (1 is not considered a prime number by convention) import time def isprime(n): if n == 2: return 1 if n % 2 == 0: return 0

Re: Problem with Threads

2012-12-19 Thread Dave Angel
On 12/19/2012 12:11 PM, Kwnstantinos Euaggelidis wrote: I have this code for Prime Numbers and i want to do it with Threads.. Any idea.?? Why do you want to do it with threads? Is it to speed up the processing? (Guessing that partly because of your printing elapsed time. Chances are running

Re: Problem with Threads

2012-12-19 Thread Hans Mulder
On 19/12/12 18:11:37, Kwnstantinos Euaggelidis wrote: I have this code for Prime Numbers and i want to do it with Threads.. Any idea.?? Why would you want to do that? It's not going to be any faster, since your code is CPU-bound. You may have several CPUs, but CPython is going to use only one

Re: Fwd: Problem with threads in python????????

2008-02-27 Thread James Matthews
Yes On Wed, Feb 27, 2008 at 3:56 AM, [EMAIL PROTECTED] wrote: On Feb 26, 7:56 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R [EMAIL PROTECTED] escribió: Hai, Is it possible to share a single variable between multiple

Re: Fwd: Problem with threads in python????????

2008-02-26 Thread Gabriel Genellina
En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R [EMAIL PROTECTED] escribió: Hai, Is it possible to share a single variable between multiple threads. For eg: Class A: thread_init() def run(): fun1() def fun(): assume some arithmatic

Re: Fwd: Problem with threads in python????????

2008-02-26 Thread castironpi
On Feb 26, 7:56 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R [EMAIL PROTECTED]   escribió: Hai,           Is it possible to share a single variable between multiple threads. For eg: Class A:          thread_init()        def

Problem with threads in python????????

2008-02-25 Thread Manikandan R
Hai, Is it possible to share a single variable between multiple threads. For eg: Class A: thread_init() def run(): fun1() def fun(): assume some arithmatic operation is going on according to the input given and each fun will *give different

Fwd: Problem with threads in python????????

2008-02-25 Thread Manikandan R
Hai, Is it possible to share a single variable between multiple threads. For eg: Class A: thread_init() def run(): fun1() def fun(): assume some arithmatic operation is going on according to the input given and each fun will *give different

Problem ... with threads in Python

2005-10-26 Thread Negoescu Constantin
Hello. Iknow that Python is not fully threadsafe. Unlike Java, where threading was considered to be so important that it is a part of the syntax, in Python threads were laid down at the altar of Portability. But, i really have to finish a project which uses multiple threads in Python, and

Re: Problem ... with threads in Python

2005-10-26 Thread Jeremy Jones
Negoescu Constantin wrote: Hello. I know that Python is */not fully threadsafe/*. Unlike Java, where threading was considered to be so important that it is a part of the syntax, in Python threads were laid down at the altar of Portability. But, i really have to finish a project

Problem with threads

2005-07-18 Thread Stephan Popp
Hi all, I've got a problem with stopping python-threads. I'm starting a thread with twisteds reactor.deferToThread which start a methodcall in a seperate thread. In this thread a swig-wrapped c++ module is running. Now I want to stop the running thread from the main thread or another one, and

Re: Problem with threads

2005-07-18 Thread Simon Dahlbacka
You cannot really do that*. Use a flag or something that the thread checks if it should shut down. /Simon * well actually you can, sort of by using int PyThreadState_SetAsyncExc( long id, PyObject *exc) from C API. However, if you do that you swap one problem for a sh*tload of others, because of

Re: Problem with threads

2005-07-18 Thread Peter Hansen
Stephan Popp wrote: I've got a problem with stopping python-threads. I'm starting a thread with twisteds reactor.deferToThread which start a methodcall in a seperate thread. In this thread a swig-wrapped c++ module is running. Now I want to stop the running thread from the main thread or