[python-win32] Regarding Threads and locals()

Tejovathi P tejovathi.p at gmail.com
Thu Mar 20 11:37:15 CET 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



class WorkerThread(threading.Thread):

    def __init__(self, ):
         # Start the thread and invoke the run method

    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):

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

             self.workerThread = WorkerThread()

if name == _main_:
.        ....
.        .....


  i = 1   j = 2
  k = 4
        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

Ideally the locals() of func() should be passed to the GUI thread, how?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080320/ee00efd5/attachment.htm 

More information about the python-win32 mailing list