clj-python / clj-python/libpython-clj
process hanging in embeded mode on exception
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.2k
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
As a FUP of #221 which provided a new pathway to see the exception,
but does not prevent the "hanging" in an other pathway.
The simplest scenario is that we have a hanging python process by using this clojure code crash.clj
(ns train
(:require [libpython-clj2.python :refer [py.- py.] :as py]
[libpython-clj2.python.ffi :as ffi]))
(def locked (ffi/lock-gil))
(py/import-module "not existing")
and load it in embedded mode using manual-gil via:
export JDK_JAVA_OPTIONS="-Dlibpython_clj.manual_gil=true"
python -c 'from clojurebridge import cljbridge;cljbridge.load_clojure_file(clj_file="crash.clj")'
The exception thrown by python on the last line in crash.clj is swallowed by either clojurebridge or libpython-clj and the process hangs forever.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the hang with crash.clj, ffi/lock-gil, py/import-module, and clojurebridge.load_clojure_file under manual-gil. Trace how the exception from the missing module is handled between clojurebridge and libpython-clj; done means the embedded process terminates or returns instead of hanging and the exception remains visible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100