Reputation: 101
I have a TKinter program that awaits stdin and then does an action based on the stream of inputs. Then I have a node.js program that scrapes a webpage every hour and based on that, writes to stdout. Is there a way I can set up these two processes to communicate with each other in real time?
Upvotes: 0
Views: 41
Reputation: 2658
You can use the python-bridge module that I found some time ago in a similar situation and execute some python code from node. The module will keep a python process for you that you'll be able to call directly from node and you'll also get your arguments translated to python (with deep references, which is quite cool).
It has a nice Promise and template string based API so you can use it in an async
function:
await python.ex`import somemodule`
await python.ex`someFunction(${javascripArgument})`
I actually used that in one of my modules, but it's currently not operational (there are some errors that I need to understand, since it used to work) - but see these lines in scramjet-python-module.
The only remark I have that this module hasn't been updated in a year, but it doesn't seem that it'd need to - it seems safe to use to me.
Upvotes: 1