Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Unable to attach to thread #1244

Open
boravinod145 opened this issue Nov 26, 2024 · 1 comment
Open

RuntimeError: Unable to attach to thread #1244

boravinod145 opened this issue Nov 26, 2024 · 1 comment

Comments

@boravinod145
Copy link

Attaching a new thread through jpype.attachThreadToJVM after the JVM has started works perfectly for each API call. However, after a few days of running the instance, it failed to attach a new thread to the JVM and returned the following error.

File "/src/api/views.py", line 130, in convert
  core.initialise_jpype()
File "/src/app/core.py", line 34, in initialise_jpype
  jpype.attachThreadToJVM()
File "/usr/local/lib/python3.10/site-packages/jpype/_core.py", line 76, in func2
  return func2._real(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/jpype/_core.py", line 388, in attachThreadToJVM
  _jpype.attachThreadToJVM()
RuntimeError: Unable to attach to thread

Even in jpype.isJVMStarted() gives true.

@Thrameos
Copy link
Contributor

It sounds like ot ran out of handles. JPype automatically attaches to threads so there is no reason to explicitely call attach. It isn't harmful, but hasn't been necessary for years. There is however a reason to detach. If you are making lots of threads, you must detach them at the end of life or eventually you will exhaust the handle pool.

I am fairly sure this appears in the JPype documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants