简体   繁体   中英

How to access terminal Python process running on server from other script

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

如果您希望在关闭ssh会话后脚本保持运行,请在执行命令结束时添加& disown ,它将在后台运行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM