Python Forum

Full Version: running just one process shared among uses
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
a lot of programs, particularly big GUI programs like web browsers, will use the previously started process when an attempt is made to start a 2nd concurrently running process of the same program. can this be done in Python for an application to be written in Python? what would be the best way to do it?
The way I think this is normally done, is the program is split into two parts, a "manager", and the actual program. Then the manager opens a named pipe or port, and starts listening for events. If that resource already exists, then it assumes that the program is already running, and sends a message to the already running manager, something like "open http://www.google.com", and then it immediately quits after sending the message. The manager that was already running, will then see the message, and pass it to the underlying program.

Does that make sense?
You can definitely model a buss in Python. Just implement the logic: https://en.wikipedia.org/wiki/Bus_(computing)
(Aug-06-2018, 09:33 PM)nilamo Wrote: [ -> ]The way I think this is normally done, is the program is split into two parts, a "manager", and the actual program. Then the manager opens a named pipe or port, and starts listening for events. If that resource already exists, then it assumes that the program is already running, and sends a message to the already running manager, something like "open http://www.google.com", and then it immediately quits after sending the message. The manager that was already running, will then see the message, and pass it to the underlying program.

Does that make sense?

yeah. once the window is open, the new process can transfer the file descriptor for the window over that named pipe connection.

but ... i have looked for such named pipes and did not find any, for many programs. they must have some other means.