Threading and Windows.

Jorge Godoy godoy at metalab.unc.edu
Mon Sep 29 08:00:48 EDT 2003


Hi!


I must have been searching in the wrong places or with the wrong
keywords but I couldn't find out how to implement something such as
what is done by the threading module on Windows (95, 98 and XP are the
ones used by my clients). My preference is for something available in
the standard library if possible.

I have a simple task where I want my GUI to be able to open several
applications simultaneously. Using the threading module everything
works perfectly on Linux but the program won't run on Windows.


Any hints on what should I do? 

The working code is really simple and is all what I need on both
platforms (pseudo-code follows):


import threading
(...)

class MyApplication(...):
(...)
     def someMethod(...):
         (...)
         def temporaryFunction():
             os.spawnv('P_NOWAIT', 'another.py', ['another.py', parameters])
         thread = threading.Thread(target = temporaryFunction)
         thread.start()
     

     def anotherMethod(...):
         (...)
         def temporaryFunction():
             os.spawnv('P_NOWAIT', 'yetanother.py', ['yetanother.py', parameters])
         thread = threading.Thread(target = temporaryFunction)
         thread.start()


and so on.

(Yes, I could factor 'temporaryFunction' and reduce 5 lines of code in
my application, but I still don't know what will be necessary to do to
make it work on Windows, so I left it as is and factor it later.)


Any hints on how to accomplish that in a portable way? Or what
additional code will I have to use to make it work in Windows?


Thanks in advance,
-- 
Godoy.     <godoy at metalab.unc.edu>




More information about the Python-list mailing list