I’m developing a simple client/server application that requires a single entry point (called from an external process); to make it simple the current architecture kinda looks like this:
Client.py
<– This is the entry pointServer.py
<– This needs to run in the backgroundShared.py
<– Shared/common variables/objects...
Inside of Shared.py
there are some shared variables/infos (such as hostname, port, passkey, etc), and also there is the setup of the various loggers used throughout the programs. Client and server communicate trough multiprocessing.connection
socket handles.
I cannot change the fact that there can be a single entry point to this application; because of this, inside of Client.py
, there is a line like this: Popen([sys.executable, 'Server.py')
that is supposed to launch another interpreter in a separate process.
This is because in the final version this will need to be shipped as an (two actually) executable, standalone, and trough a runtime check to getattr(sys, 'frozen', False)
the client/server will determine if it’s running from the live interpreter or if it’s a bundled application.
The fact is, that if i close (kill) the first interpreter, the “server” also stops running. Is this because of the Shared.py
file being imported from both the client and server? This file contains the logger objects, and in both the client and server the file is imported as a star import.
I actually need to have the Server.py
to keep running even after the Client.py
has completed its execution (so that it is returning a value to the calling process even though the server is still running), but I can’t figure this out. The obvious solution for the scripts interdependence on the objects contained in Shared.py
is to have two separate projects in two completely separate locations (or just splitting the Shared.py
file and redistribute it to both client and server), but this still doesn’t solve the problem of the 2nd interpreter terminating after the 1st is closed.
Am I missing something obvious here? Thanks in advance for the help.