Hi all,
I have a application where I use different threads. actually all is
working - BUT I just discovered that the [b]CPU is always 100 % [/
b]used.
on the 32-bit machine athlon XP, as well as on the amd 64-bit AMD
Athlon(TM) 64 X2 Dual-Core.
I have to admit I'm not used to threads. I actually use a thirdparty
scheduler http://www.webwareforpython.org/Task...Scheduler.html
but I checked and a very simple exampe with threading gives me also
all the time 100% CPU. -
-
import threading, time
-
-
class TestThread ( threading.Thread ):
-
def run ( self ):
-
print 'TEST'
-
-
t = TestThread()
-
t.start()
-
-
-
while (True):
-
pass
-
-
Does anyone know how to run this without consuming all CPU.
regards,
MJ 4 9403
On Apr 11, 2:38 am, matthiasja...@gmx.net wrote:
Hi all,
I have a application where I use different threads. actually all is
working - BUT I just discovered that the [b]CPU is always 100 % [/
b]used.
on the 32-bit machine athlon XP, as well as on the amd 64-bit AMD
Athlon(TM) 64 X2 Dual-Core.
I have to admit I'm not used to threads. I actually use a thirdparty
scheduler http://www.webwareforpython.org/Task...Scheduler.html
but I checked and a very simple exampe with threading gives me also
all the time 100% CPU.
-
import threading, time
-
class TestThread ( threading.Thread ):
-
def run ( self ):
-
print 'TEST'
-
t = TestThread()
-
t.start()
-
while (True):
-
pass
-
Does anyone know how to run this without consuming all CPU.
regards,
MJ
You need your program to sleep a while to allow a switch to other
tasks. Like so:
###
import threading, time
class TestThread(threading.Thread):
def run(self):
print 'TEST'
t = TestThread()
t.start()
while (True):
time.sleep(0.01)
pass
###
Regards
On Apr 11, 1:36 pm, "A.B., Khalid" <kha...@yahoo.comwrote:
On Apr 11, 2:38 am, matthiasja...@gmx.net wrote:
Hi all,
I have a application where I use different threads. actually all is
working - BUT I just discovered that the [b]CPU is always 100 % [/
b]used.
on the 32-bit machine athlon XP, as well as on the amd 64-bit AMD
Athlon(TM) 64 X2 Dual-Core.
I have to admit I'm not used to threads. I actually use a thirdparty
scheduler http://www.webwareforpython.org/Task...Scheduler.html
but I checked and a very simple exampe with threading gives me also
all the time 100% CPU.
-
-
import threading, time
-
-
-
-
-
class TestThread ( threading.Thread ):
-
def run ( self ):
-
print 'TEST'
-
-
-
-
-
t = TestThread()
-
t.start()
-
-
-
-
-
while (True):
-
pass
-
-
-
-
-
-
-
-
Does anyone know how to run this without consuming all CPU.
regards,
MJ
You need your program to sleep a while to allow a switch to other
tasks. Like so:
###
import threading, time
class TestThread(threading.Thread):
def run(self):
print 'TEST'
t = TestThread()
t.start()
while (True):
time.sleep(0.01)
pass
###
Regards
Thanks a lot both of you.
MJ
En Wed, 11 Apr 2007 08:36:57 -0300, A.B., Khalid <kh****@yahoo.com>
escribió:
On Apr 11, 2:38 am, matthiasja...@gmx.net wrote:
>I have a application where I use different threads. actually all is working - BUT I just discovered that the [b]CPU is always 100 % [/ b]used.
You need your program to sleep a while to allow a switch to other
tasks. Like so:
t = TestThread()
t.start()
while (True):
time.sleep(0.01)
pass
If all you want is to wait until the thread finishes, use t.join() instead
of that infinite loop.
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Huzefa |
last post by:
I am working on a amll project in Java that includes many classes.
Each of the classes has a Logger object. I have associated a
FileHandler with
each of these Logger objects. The file is the same...
|
by: Ronan Viernes |
last post by:
Hi,
I have created a python script (see below) to count the maximum number
of threads per process (by starting new threads continuously until it
breaks).
######
#testThread.py
import...
|
by: Mr. Mountain |
last post by:
In the following code I simulate work being done on different threads by
sleeping a couple methods for about 40 ms. However, some of these methods
that should finish in about 40 -80 ms take as long...
|
by: [Yosi] |
last post by:
I would like to know how threads behavior in .NET .
When an application create 4 threads for example start all of them, the OS
task manager will execute all 4 thread in deterministic order manes,...
|
by: RahimAsif |
last post by:
Hi guys,
I would like some advice on thread programming using C#.
I am writing an application that communicates with a panel over
ethernet, collects data and writes it to a file. The way the...
|
by: mareal |
last post by:
I am trying to write a basic load balancer (in our web service) solution. The
purpose of this load balancer is to keep an array updated with server status.
We have several servers that can be...
|
by: cj |
last post by:
I'm writing a TCP/IP server app that will have many simultaneous
connections. The main thread listens for new connections and starts a
thread to handle each requested connection. These are short...
|
by: jgbid |
last post by:
Hi, I'm trying to build an IP Scanner inc c# for a specific port (80)
and for specific IP Ranges.
For example 24.36.148.1 to 24.36.148.255
My first step was to use TcpClient, but there are...
|
by: Jon Slaughter |
last post by:
"Instead of just waiting for its time slice to expire, a thread can block
each time it initiates a time-consuming activity in another thread until the
activity finishes. This is better than...
|
by: tdahsu |
last post by:
All,
I'd appreciate any help. I've got a list of files in a directory, and
I'd like to iterate through that list and process each one. Rather
than do that serially, I was thinking I should...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |