简体   繁体   中英

Call a python function from java, while the python script was already running

I need to call a python function from java, pass it an array, and get an array back. I realise I can do this with Jython.

The problem is, my python script needs to load a very heavy (and slow to load) model in order to run the function. So I was wondering if I could leave the python script on somehow, and let it listen to the next function call. Any ideas on this? I could have the java i/o files and communicate like this, but this seems like a (smaller though) bottleneck as well.

I read something about multiprocessing in python, but I am not sure this is the way to go https://docs.python.org/3/library/multiprocessing.html#multiprocessing-managers

通过设置python袜子服务器和java客户端进行通信,我能够使python脚本保持运行。

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