jwiegley / emacs-async

Simple library for asynchronous processing in Emacs
GNU General Public License v3.0
828 stars 68 forks source link

Interprocess communication is not really working in spite of async-test-5 #104

Closed TobiasZawada closed 1 year ago

TobiasZawada commented 6 years ago

There exists a test case async-test-5 for async-send.

I modified that test case a bit to make debugging easier:

(defun async-test-5 ()
  (interactive)
  (message "Starting async-test-5...")
  (let ((proc
         (async-start
          ;; What to do in the child process
          (lambda ()
        (with-temp-buffer
          (insert (format "Value of `async-callback': %S\n" async-callback))
          (async-send :hello "world")
          ;; wait for messages
          (while (let* ((msg (async-receive))
                (str (plist-get msg :goodbye)))
               (insert (format "Child got message: %s\n" str))
               (sleep-for 1)
               (null (string-equal str "goodbye"))))
          (buffer-string)))

          ;; What to do when it finishes
          (lambda (result)
            (if (async-message-p result)
                (message "Got hello from child process: %s"
                         (plist-get result :hello))
              (message "Async process done, result: %s"
                       result))))))
    (setq async-message-from-child nil)
    (async-send proc :goodbye "everyone")
    (sleep-for 1)
    (async-send proc :goodbye "just for you")
    (sleep-for 1)
    (async-send proc :goodbye "goodbye"))
  (message "Starting async-test-5...done"))

Running async-test-5 interactively outputs following message:

Async process done, result: Value of `async-callback': nil
Child got message: everyone
Child got message: just for you
Child got message: goodbye

As one sees one can send messages from the mother process to the child but sending messages from the child to the mother process (the (async-send :hello "world") thing) fails.

async-send uses the value of async-callback in the child and that variable is never set in the child. The output string Value of 'async-callback': nil proves that.

Note that this text is copied from a question on emacs.stackexchange.com.

Fuco1 commented 1 year ago

Fixed in #167

@thierryvolpiatto we can close this.

thierryvolpiatto commented 1 year ago

Matus Goljer @.***> writes:

Fixed in #167

@thierryvolpiatto we can close this.

Thanks, well both ticket have been closed automatically while merging your PRs.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.*Message ID: @.***>

-- Thierry