Python Forum
running just one process shared among uses - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: running just one process shared among uses (/thread-11477.html)



running just one process shared among uses - Skaperen - Jul-10-2018

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?


RE: running just one process shared among uses - nilamo - Aug-06-2018

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?


RE: running just one process shared among uses - Vysero - Aug-06-2018

You can definitely model a buss in Python. Just implement the logic: https://en.wikipedia.org/wiki/Bus_(computing)


RE: running just one process shared among uses - Skaperen - Aug-07-2018

(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.