jwiegley / emacs-async

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

Add optional ON-FAILURE-FUNC argument to async-start #152

Closed KaiHa closed 2 years ago

KaiHa commented 2 years ago

First of all thanks, for this awesome package. I regularly use async together with ob-async and sometimes encounter the case where my START-FUNC code calls signal or error. The only way to handle signals seems to be to use async-wait, but that does not really fit well with my use case. Therefore my question, is there already a better way to handle signals that is built into async and that I am not aware of?

If not, would it be a good idea to make START-FUNC of async-start an optional cons '(START-FUNC . ON-FAILURE-FUNC), with ON-FAILURE-FUNC being called in case of a signal?

If yes, I could give it a stab.

thierryvolpiatto commented 2 years ago

Kai @.***> writes:

First of all thanks, for this awesome package. I regularly use async together with ob-async and sometimes encounter the case where my START-FUNC code calls signal or error. The only way to handle signals seems to be to use async-wait, but that does not really fit well with my use case. Therefore my question, is there already a better way to handle signals that is built into async and that I am not aware of?

It works quite well to catch error from START-FUNC and write it to a temp file and read the file from the CALLBACK, see async-byte-compile-file for example.

-- Thierry

KaiHa commented 2 years ago

It works quite well to catch error from START-FUNC and write it to a temp file and read the file from the CALLBACK, see async-byte-compile-file for example.

Thanks, you are right. That is indeed an obvious and easier solution to my problem.