emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there any easy way to fork in elisp? Why not?


From: Rudi C
Subject: Is there any easy way to fork in elisp? Why not?
Date: Tue, 26 Oct 2021 16:14:37 +0330

There are some scripts that I find convenient to code in elisp,  and I like to be able to run these with little startup time. 

The natural solution is to use `emacs --batch --eval` together with `server-eval-at` to reuse an already loaded server, but this solution needs a lot of throwaway servers already started and a load balancer. (Is there a Jupyter kernel for elisp? I already have a prototype server (https://github.com/NightMachinary/JupyterGarden) that starts throwaway Jupyter kernels and load-balances requests to them.)

If the server could just fork, eval the request, return it, and die, everything would be easy and painless. 

The fork API could be:
```
(let-fork ((some_val (expensive_compute)) ...)  
 (lambda()
   (message "Computed: %s" some_val)))
``` 
Where emacs forks for every binding, and computes the results, and finally, asynchronously calls the supplied callback function with all of the bindings available, similar to a closure.

I am sure there are better API designs, but my point is that this fork API should be very easy and work with synchronous third-party code, just like a shell (or GNU Parallel). Parallelism via multiprocessing should be easy and painless.

The third-party packages for parallelism that I have skimmed, start a fresh emacs instance, and do not fork, which is useless, as all the needed data and behavior needs to be manually reloaded by the user.

PS: Please use reply-to-all, I am not currently subscribed to the list. Thank you.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]