Reputation: 425
My program loads a few files once for each instance (when they are needed for the first time). The problem is when called through command line, every call creates a new instance. Now my program is called from another subsystem in a loop and since every time it has to load all those files, it is very slow.
So is there a way to somehow keep a reference to an instance of the program and execute commands on the same instance every time? Any other solutions to this?
Upvotes: 0
Views: 226
Reputation: 3721
Either you have to implement the loop inside your program so it will be called only once.
Otherwise you need to start your program as a daemon and make it waiting for commands, either on stdin or a socket or pipe for commands.
Upvotes: 1