[Python-Dev] GIL, Python 3, and MP vs. UP

Josiah Carlson jcarlson at uci.edu
Wed Sep 21 19:38:49 CEST 2005


Antoine Pitrou <solipsis at pitrou.net> wrote:
> 
> 
> > The best way to make people stop complaining about the GIL and start  
> > using
> > process-based multiprogramming is to provide solid, standardized support
> > for process-based multiprogramming.
> 
> 100% agreed. I needed a portable way to know if a program was already
> running (and then to send it a simple command), the only simple solution
> I found was to listen on a local TCP socket and store the port number in
> a file in a known location. Not very elegant IMO.

On *nix, use a unix domain socket (location in the filesystem which acts
as a listening socket).  On Windows, you can use cTypes, pywin32, etc.,
to create a global mutex and/or COM interface.

Alternatively, you can write your own cross-platform registry for
services, have it running on your machines all the time, and never worry
again.

Or one can pick a port to use on all systems and not bother with the the
file listing the port, ignore domain sockets, COM interfaces, and
work-alikes.


In terms of IPC, the application may determine which is most usable.  If
one had a service distributed across multiple machines, sockets are
necessary.  If one only needed local access, shared memory (perhaps via
a memory mapped file) would be significantly faster.  In the case of
multiple machines with multiple processors, one could opt for shared
memory locally but sockets globally, which could complicate the
interface, result in non-uniform performance for transfers, which may
then necessate complicating the application in order to gain the highest
throughput (I've done this previously using MPI, it can be a PITA).


 - Josiah



More information about the Python-Dev mailing list