I have this python setup using objects that can perform specific tasks for I2C protocol. Rather than having the script create objects and run a single task when run from a command line command, is there a way to have the objects 'stay alive' in the background and somehow feed the program new data from the command line?
The general idea is to have something running on a remote pc and use ssh to send commands (new data) over to the program.
One idea I had was to have the program constantly check (infinite loop) for a data file containing a set of tasks to perform and run those when it exists. But it seems like it could go awry if I were to sftp a new data file over because the program could be reading the one that already exists and cause undesirable effects.
I'm sure there are many better ways to go about a task like this, any help will be appreciated.
You can try and use a client-server or sockets approach. Your remote PC has a server running listening to commands or data coming into. Your client or local computer can send commands on the port and ip that the remote PC is listening to. The server then parses the data coming in, looks at whatever commands you have defined and executes them accordingly.
Running python in the background and feeding data