Liking cljdoc? Tell your friends :D

sci.interrupt

Opt-in, interrupt-fn aware overrides for core functions that iterate over host sequences without ever entering an interpreted function, and therefore never hit the per-fn-entry :interrupt-fn check.

This namespace is NOT loaded by default and adds nothing to a standard SCI build unless you require it. Merge clojure-core into your context's clojure.core namespace to make these functions interruptible:

(require '[sci.core :as sci]
         '[sci.interrupt :as interrupt])

(sci/init {:interrupt-fn my-interrupt-fn
           :namespaces {'clojure.core interrupt/clojure-core}})

Each override reads :interrupt-fn from the current context at call time and falls back to the native function when no :interrupt-fn is configured, so merging clojure-core is always safe.

Opt-in, interrupt-fn aware overrides for core functions that iterate over
host sequences without ever entering an interpreted function, and therefore
never hit the per-fn-entry `:interrupt-fn` check.

This namespace is NOT loaded by default and adds nothing to a standard SCI
build unless you require it. Merge `clojure-core` into your context's
`clojure.core` namespace to make these functions interruptible:

    (require '[sci.core :as sci]
             '[sci.interrupt :as interrupt])

    (sci/init {:interrupt-fn my-interrupt-fn
               :namespaces {'clojure.core interrupt/clojure-core}})

Each override reads `:interrupt-fn` from the current context at call time and
falls back to the native function when no `:interrupt-fn` is configured, so
merging `clojure-core` is always safe.
raw docstring

clojure-coreclj/s

Map of clojure.core symbol -> interrupt-fn aware replacement var. Each value is a real SCI var on the shared clojure.core namespace object (built via copy-vars/new-var, like the built-in core vars), so it carries proper :ns/:name/:sci/built-in metadata. Merge into {:namespaces {'clojure.core ...}}.

Map of `clojure.core` symbol -> interrupt-fn aware replacement var. Each value
is a real SCI var on the shared `clojure.core` namespace object (built via
`copy-vars/new-var`, like the built-in core vars), so it carries proper
`:ns`/`:name`/`:sci/built-in` metadata. Merge into `{:namespaces {'clojure.core ...}}`.
sourceraw docstring

clojure-stringclj/s

Map of clojure.string symbol -> interrupt-fn aware replacement var. Each value is a real SCI var on the shared clojure.string namespace object (built via copy-vars/new-var, like the built-in core vars), so it carries proper :ns/:name/:sci/built-in metadata. Merge into {:namespaces {'clojure.string ...}}.

Map of `clojure.string` symbol -> interrupt-fn aware replacement var. Each value
is a real SCI var on the shared `clojure.string` namespace object (built via
`copy-vars/new-var`, like the built-in core vars), so it carries proper
`:ns`/`:name`/`:sci/built-in` metadata. Merge into `{:namespaces {'clojure.string ...}}`.
sourceraw docstring

get-interrupt-fnclj/s

(get-interrupt-fn ctx)

Returns the :interrupt-fn configured on ctx (as produced by sci/init), or nil when none was set. Use this from host functions you expose to make them interrupt-fn aware, e.g. (get-interrupt-fn (sci.ctx-store/get-ctx)).

Returns the `:interrupt-fn` configured on `ctx` (as produced by `sci/init`),
or nil when none was set. Use this from host functions you expose to make them
interrupt-fn aware, e.g. `(get-interrupt-fn (sci.ctx-store/get-ctx))`.
sourceraw docstring

interrupt!clj/s

(interrupt!)
(interrupt! msg)
(interrupt! msg data)

Throws an interrupt signal that sandboxed code cannot catch. Call this from your :interrupt-fn instead of throwing a plain exception, so evaluated code cannot swallow the interrupt with try/catch and keep running. The thrown value is an ex-info carrying a private marker; sci's try refuses to hand it to user catch clauses, and sandboxed code cannot forge it. It propagates to the host calling eval-string.

Throws an interrupt signal that sandboxed code cannot catch. Call this from
your `:interrupt-fn` instead of throwing a plain exception, so evaluated code
cannot swallow the interrupt with `try`/`catch` and keep running. The thrown
value is an `ex-info` carrying a private marker; `sci`'s `try` refuses to hand
it to user `catch` clauses, and sandboxed code cannot forge it. It propagates
to the host calling `eval-string`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close