skip to Main Content

I’m currently working to send image data, in the form the byte arrays, from Python to JavaScript. I tried to use Redis as a means of in-memory, persistent communication channel, but it seems like bad design to force users to separately run redis-cli in the terminal. I tried to see if I can launch a Redis server using Python, but I could not find anything for that either. Is there an efficient, user-friendly way of setting up this type of communication? Would socket programming be a good way of setting up this communication channel as well?

2

Answers


  1. Chosen as BEST ANSWER

    To answer my own question, I decided to go down the path of using websockets to achieve bidirectional communication between Python and JavaScript. Specifically, I set up a websocket using tornado, setup Python and JavaScript cilents, and communicate via event-driven programming.

    I really wanted to steer away from calling redis-cli or any other bash commands via subprocess, and I think using websockets is an elegant and efficient solution.


  2. You can start redis-cli from your python code using subprocess. As per my understanding of your problem, you have to use subprocess.Popen(), to run a terminal command in a separate thread(in parallel). If want your python code to wait for the terminal command to finish, you can use subprocess.call()

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search