clj-python / clj-python/libpython-clj

process hanging in embeded mode on exception

Open
#233 2 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.