Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Regarding Threads and locals()

Reply
Thread Tools

Regarding Threads and locals()

 
 
Teja
Guest
Posts: n/a
 
      03-20-2008
Hi all,

I have a GUI applicaion(along with threads). When the run button is
pressed in the GUI a separate thread starts( Thread is created using
beginthreadex) and does the
required activity.
Now, while the thread is being executed, i want the locals() present
inside the thread's run function to be avaialbe in the GUI class from
where the thread class is being created

EG:
----------------------
main.py
--------------------------
class WorkerThread(threading.Thread):

def __init__(self, ):
threading.Thread.__init__(self)
# Start the thread and invoke the run method
self.start()

def run(self):
# Start the thread. It executed self.func() as a separate
thread
self.workerThread, tid = win32process.beginthreadex(None,
0 , self.func ,(), 1)
.......

def func(self):
execfile(temp.py)

class GUI(wxFrame):
def __init__(self):
.....
.....
def CreateThread(self):

self.workerThread = WorkerThread()


if name == _main_:
.....
.. ....
.. .....
---------------------
temp.py
------------------
i = 1
j = 2
k = 4
while(10000):
print i
print j
print k
i = 1+1
j = j+2
k = k + 3


Now, while the thread is executin func and printing i, j, k , In the
main GUI thread how do i get the values of i, j ,k
I tried with sys.modules, sys._current_frames, vars(). But nothing
worked out.

Ideally the locals() of func() should be passed to the GUI thread,
how?
 
Reply With Quote
 
 
 
Reply

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
Java Threads - Get running threads Pedro Pinto Java 2 04-08-2008 11:44 PM
[new to threads] threads with UI and loop Une bévue Ruby 0 06-14-2006 10:22 AM
TB View, Threads, Threads with unread The Invisible Man Firefox 1 03-20-2006 02:09 AM
Standard Threads vs Weightless Threads yoda Python 2 08-01-2005 09:12 PM
threads without threads sindica@gmail.com C Programming 4 08-27-2004 09:25 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57