Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Thread get off from CPU occasionally. I suspect.

Thread Tools

Thread get off from CPU occasionally. I suspect.

Posts: n/a

I'm using Python 2.6 and using the threading module.
In a python module (parent module) I'm importing main() function from
another python module. I'm runnin this main() function on a Python
thread so that I can periodically check in the parent thread/module if
the new thread is up and running. This information that the python
script running on the new thread is still up and running is passed to
a 3rd party application (in a manner known to 3rd party).

As 3rd party is waiting for this new thread to finish. It waits for 3
mins and on told to it by the parent thread that new thread is still
running, the 3rd party then starts to wait again for 3 mins.

I've successfully implemented this functionality and it runs well
except for a rare chance when the new thread does not completely runs.
However, most of the cases the new thread runs completely. I cannot
understand why and when the new thread gets off the CPU or crashes or
any other thing?

I'm not able to figure out what is happening.?

The code in the parent thread that starts the new thread is as

exec("from " + passed_script_file + " import main") #imported main
function. It works.
import threading
import time
p = RunTestScript(main)
t_nought = time.time()
seconds_passed = 0
keep_alive_set = 0
while p.isAlive() == True:
if p.isAlive() == True:
seconds_passed = time.time() - t_nought
if seconds_passed >= 120:
t_nought = time.time()
if keep_alive_set != 1: # 3rd party way of informing
that the new thread is alive.
request = 'SET SHARED VAR KEEP_ALIVE=%d' %(1)
res = handle.submit('local', 'VAR', request)
if (res.rc != 0):
logSystemError('[PyInt] Error: STAF local VAR %s
failed, RC: %s, Result: %s\n' % (request, res.rc,
return res.rc
keep_alive_set = 1

Earlier, when I did not run the main function on a new thread, it
always used to run completely. I used to run it as:

exec("from " + passed_script_file + " import main")
retCode = main()

Thanks and regards,
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How CPU Features Affect CPU Performance Ian Front Page News 0 02-18-2010 03:28 PM
How , system cpu and user cpu times calculates pavunkumar C Programming 1 02-27-2009 08:29 AM
HELP! Trying to understand the logic behind CPU core speeds and whole CPU speed. dimon Computer Support 4 11-10-2006 04:01 PM
100% Cpu usage IS ****ING ME OFF :( Home Theatre Guy Firefox 21 07-31-2006 04:17 AM
Pentium CPU vs Intel Celeron CPU and the Wireless Mouse kirk lives! Computer Support 4 05-02-2004 06:59 PM