0

Consider situation:

I have an Ubuntu server with installed Python, tensorflow and other libs. My code is python script, that load several models, some of them pretrained vectors .bin, some files from server folders, etc.

When i run script in terminal it launch interactive session, where i input some text and script output me back (like chatbot). During answer it call my Ai models (Tensorflow, keras).

Question: how do i access this running session from other python script? I mean i want use it as a function: to send text and receive answer back. And of course i need to run this terminal session in background for long time.

I read this and similar answers, but not sure is that right solution (seems not a full): In Linux, how to prevent a background process from being stopped after closing SSH client

What i am asking, commonly is done by REST server with API that expose and then this api is called from a external code. But there is no API wotking: Tensorflow throw errors when run via Flask (was not able to fix).

Vic Nicethemer
  • 1,081
  • 3
  • 16
  • 38

1 Answers1

0

If you want your script stays up after closing ssh session, add & disown at the end of your execution command and it will run in background.

Siyavash vaez afshar
  • 1,303
  • 10
  • 12
  • but how do i corespond and send message to screen ? to get answer back – Vic Nicethemer May 25 '19 at 07:15
  • 1
    Sorry I didn't notice there is no api. change the line which gets raw input to read it from file. then the only thing you need to do is update the file which your script is looking to and set time interval to check it frequently . – Siyavash vaez afshar May 25 '19 at 07:25