GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Free-threaded CPython: serialize start_jvm(), define the JPype proxy classes once, add a thread stress test by tae898 · Pull Request #454 · humemai/arcadedb-embedded-python

This repository was archived by the owner on Nov 21, 2026. It is now read-only.

Conversation

@tae898

@tae898 tae898 commented Oct 22, 2026

Copy link
Copy Markdown

Fixes #453.

Threads whose first call is create_database() or open_database() raced into jpype.startJVM, and the first register_function() or on() from several threads defined the JPype proxy class more than once. Both are fixed here. This also adds a thread stress test, makes the suite honest on a free-threaded CPython, and documents what stays open there. Measurements are in the issue.

What changes:

  • jvm.py: start_jvm() runs under a lock (a decorator, signature unchanged). The thread that loses the race takes the existing "JVM already started" branch. This is a bug with the GIL too: 3 of 3 runs of 16 threads failed with JVM is already started on ordinary 3.14.
  • callbacks.py: the function and event proxy classes are defined under a lock with a second check, so they are defined once and not leaked.
  • tests/test_free_threading.py: many threads against one database and one database each, compared with a sequential run (inserts, numpy vector rows, queries, vector searches, Python functions, record events, the first-call JVM start, the one-time proxy classes). It passes with the GIL. FT_THREADS and FT_REPEAT scale it.
  • tests/test_python_callbacks.py: test_registering_again_and_again_does_not_grow_the_python_heap is xfail (not strict) only when sys._is_gil_enabled() is false, because the heap grows on 3.14t only and the cause is not attributed. With the GIL nothing changes.
  • Docs: the "Free-threaded Python" entry on the Known Engine Issues page now covers the two fixes, the heap growth, the rare SIGSEGV in JPype's JPHintsConversion::matches on concurrent first Java calls (the warm-up precaution is marked unverified), and the exit hang after a non-main thread used Java (jpype#1169) with its two workarounds, jpype.java.lang.Thread.detach() at the end of the thread or jpype.config.destroy_jvm = False (which skips the JVM shutdown hooks). The bindings keep JPype's default. The page intro, docs/api/jvm.md (start_jvm() is safe to call from several threads) and docs/development/testing.md (a row for the new test, and the sentence that no test is xfail) agree with it.

Swept: grepped bindings/python for free-threading, GIL and start_jvm text in the docs, the source and CI; the three docs above are the only places that describe it. No wheel contents change besides the two source files, no public API changes, and the bindings default for destroy_jvm is untouched.

Checked here: uvx pre-commit run --files on the six changed Python and Markdown files passes, mkdocs build --strict passes, and the xfail condition evaluates true on 3.14t with PYTHON_GIL=0 and false on 3.14 with the GIL. The whole suite ran on 3.14t and on 3.14 with the GIL before the heap mark: it differed in that one test only. The stock-wheel run of the full suite on 3.12 against the final commit is queued on the laptop and its result will follow in a comment on this PR.

Not verified: JPype master (which carries jpype#1503), 3.13t, the warm-up precaution, and whether the SIGSEGV and the heap growth are in JPype or in our glue.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tae898 and others added 2 commits October 22, 2026 12:19
@tae898 @claude
Free-threaded CPython: serialize the JVM start, define the JPype prox…
457f194
…y classes once, add a thread stress test

start_jvm() holds a lock: threads whose first call was create_database() or open_database() raced into jpype.startJVM() and all but one
failed with "Failed to start JVM" (with the GIL too). The function and event proxy classes are defined under a lock: threads that registered
their first function together each defined a class. tests/test_free_threading.py runs many threads against one database and one database
each and compares with a sequential run. known-issues.md lists what stays open on 3.14t.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tae898 @claude
Free-threaded CPython: xfail the heap-growth test there, document the…
81877e9
… open JPype issues

test_registering_again_and_again_does_not_grow_the_python_heap grows the Python heap by about 520 to 610 bytes per register, on, remove cycle on 3.14t only; it is marked xfail (not strict) when sys._is_gil_enabled() is false. The Known Engine Issues entry for free-threaded Python now covers the heap growth, the rare SIGSEGV in JPHintsConversion::matches on concurrent first Java calls, and the exit hang after a non-main thread used Java (jpype#1169) with its two workarounds. testing.md no longer says that no test is xfail.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@tae898

tae898 commented Oct 22, 2026

Copy link
Copy Markdown
Author

Local full suite on the stock wheel (build.sh linux/amd64 3.12 against the synced 7f65a6e engine libraries, uv run pytest), run on the head of this branch. Raw result, not yet interpreted:

run.log:BUILD FAILED

🤖 Generated with Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tae898 @claude
tests: Bandit annotations in test_free_threading (subprocess import a…
0fe4c33
…nd call, test-owned UDF name)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tae898
tae898 merged commit dc18278 into main Oct 22, 2026
42 of 44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@tae898
tae898 deleted the ft-free-threading branch October 22, 2026 05:35
@tae898 tae898 mentioned this pull request Oct 24, 2026
Bridge: float vectors cross as one binary buffer, not as JSON text or one JPype call per element #496
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Free-threaded CPython and threads that start the JVM together: serialize start_jvm(), define the JPype proxy classes once, add a thread stress test

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@tae898
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.