Threading and Windows.

Peter Abel PeterAbel at gmx.net
Mon Sep 29 16:25:15 EDT 2003


Jorge Godoy <godoy at metalab.unc.edu> wrote in message news:<m3smmfu7m7.fsf at ieee.org>...
> 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,

http://www.python.org/doc/current/lib/os-process.html says
...
...
...
spawnl(mode, path, ...) 
spawnle(mode, path, ..., env) 
spawnlp(mode, file, ...) 
spawnlpe(mode, file, ..., env) 
spawnv(mode, path, args) 
spawnve(mode, path, args, env) 
spawnvp(mode, file, args) 
spawnvpe(mode, file, args, env) 
...
...
...
Availability: Unix, Windows. spawnlp(), spawnlpe(), spawnvp() and
spawnvpe() are not available on Windows. New in version 1.6.
...
...
...
Regards
Peter




More information about the Python-list mailing list