Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
NEXT VERSION []
------------------
* Crash of python's main thread when one attempts to interrupt it fixed.

0.1.1 [2025.02.13]
------------------
* Number of deadlocks in `runPyInMain` fixed:
Expand Down
4 changes: 3 additions & 1 deletion src/Python/Internal/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ mainThread lock_init lock_eval = do
case r_init of
False -> pure ()
True -> mask_ $ fix $ \loop ->
takeMVar lock_eval >>= \case
(takeMVar lock_eval `catch` (\InterruptMain -> pure HereWeGoAgain)) >>= \case
EvalReq py resp -> do
res <- (Right <$> runPy py) `catch` (pure . Left)
putMVar resp res
Expand All @@ -373,6 +373,7 @@ mainThread lock_init lock_eval = do
Py_Finalize();
} |]
putMVar resp ()
HereWeGoAgain -> loop


doInializePythonIO :: IO Bool
Expand Down Expand Up @@ -431,6 +432,7 @@ doInializePythonIO = do
data EvalReq
= forall a. EvalReq (Py a) (MVar (Either SomeException a))
| StopReq (MVar ())
| HereWeGoAgain

data InterruptMain = InterruptMain
deriving stock Show
Expand Down
Loading