Why I made this package:
This package was created to quickly bridge a set of Python machine learning models with a NodeJS service.
This solution works, but there is an inherent cost to spinning up the Python processes.
For applications that are not time sensitive this solution will work and requires little modification to an existing Python script.
Since we're working with std.in/out, be aware that any print
lines in your Python file will be piped to the PyPool.execute
callback.
Sample JS File
const PyPool = ;// creates a pool of five readily available processes running the same scriptconst pool = count: 5 script:'/path/to/your/script.py'; const args = 12345;// takes an available process and executes with argspool;
Sample Python File
import sysimport jsonimport numpy as np lines = return data = np_data = result = print(result, end=') if __name__ == '__main__':