Trying to make a small example on how to do IPC with Elisp using Python for the server. My source of information is this Here is the code I have right now.


(let ((process-connection-type nil)
      (arguments (list "./server.py")))
  (apply 'start-process "my-process" "*my-process-buffer*" "python" arguments)
  (set-process-filter (get-process "my-process") 'my-callback))

(defun my-callback (process msg)
  (message msg))

(defun kill-my-process ()
  (delete-process "my-process"))

(defun send-to-my-process (msg)
  (interactive "sEnter message: ")
  (process-send-string "my-process" (concat msg "\n")))

(provide my-process)


import sys

sys.stdout.write("STARTING MY PROCESS!")
for line in sys.stdin:

The problem I have is that the process starts ok, but I can only see "STARTING MY PROCESS!" printed nothing when I do send-to-my-process.

My question is, what do I need to change in order for messaging to work in the above example?

Update: Added suggested fixes.


1 Answer 1


On the elisp side, you should send a final newline to the client:

(process-send-string "my-process" (concat msg "\n")))

On the python side, you need to flush the output since you're using a pipe:

  • That helped some, now "STARTING MY PROCESS!" prints in the messages buffer but still when I do send-to-my-process nothing happens. Commented May 6, 2016 at 16:45
  • 1
    It works for me using Python 3. It doesn't work using Python 2, and I'm too lazy to work out why.
    – jch
    Commented May 8, 2016 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.