Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C-c C-c in the repl comint-interrupt-subjob kills inf-clojure instead of interrupting current evaluation #206

Closed
Inc0n opened this issue Nov 13, 2022 · 3 comments

Comments

@Inc0n
Copy link
Contributor

Inc0n commented Nov 13, 2022

Expected behavior

Interrutps currently evaluted expression

Actual behavior

Kills inf-clojure session.

Steps to reproduce the problem

Put this into the repl, it sleeps for 1sec, and before it finishes evaluating. Interrupt it using C-c C-c.

(Thread/sleep 1000)

This will kill inf-clojure with this output

Process inf-clojure .clojure exited abnormally with code 130

Environment & Version information

inf-clojure version information

3.2.1

Lein/Boot version

Clojure CLI version 1.11.1.1189

Emacs version

28.2

Operating system

Mac Monterey M1

@Inc0n
Copy link
Contributor Author

Inc0n commented Nov 13, 2022

Here is some research I have done.
https://clojureverse.org/t/interrupt-clj-evaluation-without-exiting-repl/4046
TLDR, it is not possible because of clojure cli itself.
Real shame...

@Inc0n Inc0n closed this as completed Nov 13, 2022
@dpsutton
Copy link
Contributor

Yeah. nrepl uses an interruptible evaluation that can sometimes be stopped. I think the fundamental tool they are relying on is deprecated though.

(defn- interrupt-stop
  "This works as follows

  1. Calls interrupt
  2. Wait 100ms. This is mainly to allow thread that respond quickly to
     interrupts to send a message back in response to the interrupt. Significantly,
     this includes an exception thrown by `Thread/sleep`.
  3. Asynchronously: wait another 5000ms for the thread to cleanly terminate.
     Only calls `.stop` if it fails to do so (and risk state corruption)

  This set of behaviours strikes a balance between allowing a thread to respond
  to an interrupt, but also ensuring we actually kill runaway processes.

  If required, a future feature could make both timeouts configurable, either
  as a server config or parameters provided by the `interrupt` message."
  [^Thread t]
  (.interrupt t)
  (Thread/sleep 100)
  (noisy-future
   (Thread/sleep 5000)
   (when-not (= (Thread$State/TERMINATED)
                (.getState t))
     (.stop t))))

And .stop is deprecated as "inherently unsafe": javadocs

@Inc0n
Copy link
Contributor Author

Inc0n commented Nov 13, 2022

Well, there is also this I found about nrepl and rebel/readline, bhauman/rebel-readline#180 (comment).
But I do not know enough about nrepl and repl options to incooperate this :eval option in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants