Control stript which is runing in background.

jak nospam at please.ty
Thu Dec 31 18:26:09 EST 2020


Il 31/12/2020 22:43, Cameron Simpson ha scritto:
> On 31Dec2020 18:07, jak <nospam at please.ty> wrote:
>> Il 31/12/2020 11:43, Petro ha scritto:
>>> I would like to make something like this:
>>> A python script would run headlessly in the background.
>>> I would like to control the script from the command line using other python scripts or from the python shell.
>>>  From time to time I would ask the main script to create a popup window with an image or a plot.
>>> What would be the proper way to approach it. How to make communication between two scripts?
>>
>> using named pipes would be an alternative. A small example that
>> produces an echo for windows.
> 
> A Windows named pipe seems to be more like a UNIX-side "UNIX domain
> socket" than a UNIX side "named pipe".
> 
>> For linux it's simpler using os.mkfifo:
> 
> Not really. For Linux (and of course other UNIXen) you really want a
> UNIX domain socket, not a a name pipe (as from mkfifo).
> 
> The reason is that a socket (and a Windows pipe, from my limited
> understanding) creates a new distinct connection when you open it. (The
> other end has to accept that connection, at least in UNIX).
> 
-----------------
> The problem with a UNIX pipe is that every client (your command line
> control script) _share_ the same pipe - if two scripts un at once there
> will be a failure. If you contrive some locking scheme then you can
> share a named pipe in UNIX because only once client will use the pipe at
> a time.
> 

This is not completely true, in fact requests can be queued as they 
would be with sockets and it is their real job. The most important 
difference is that sockets are a limited resource on a system.

> Just something to keep in mind.
> 
> Cheers,
> Cameron Simpson <cs at cskk.id.au>
> 



More information about the Python-list mailing list