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

OSError: JVM is already started #238

Open
lilili111a opened this issue Dec 28, 2023 · 1 comment
Open

OSError: JVM is already started #238

lilili111a opened this issue Dec 28, 2023 · 1 comment

Comments

@lilili111a
Copy link

When I connect to Phoenix using Python, I intend to initialize a connection in each process. However, I encountered the following issues:
User

Traceback (most recent call last):
File "/usr/local/python3.9.13/lib/python3.9/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/local/python3.9.13/lib/python3.9/multiprocessing/pool.py", line 51, in starmapstar
return list(itertools.starmap(args[0], args[1]))
File "/usr/appsoft/iespy/beyond_limit/nopandas.py", line 300, in run_bt
bt_instance.run() # ▒▒▒▒▒▒▒▒һ▒▒ run ▒▒▒▒▒ִ▒▒ʵ▒▒▒▒▒Ҫ▒߼▒
File "/usr/appsoft/iespy/beyond_limit/nopandas.py", line 289, in run
results = list(executor.map(self.Thread_f, time_slot))
File "/usr/local/python3.9.13/lib/python3.9/concurrent/futures/_base.py", line 609, in result_iterator
yield fs.pop().result()
File "/usr/local/python3.9.13/lib/python3.9/concurrent/futures/_base.py", line 446, in result
return self.__get_result()
File "/usr/local/python3.9.13/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
raise self._exception
File "/usr/local/python3.9.13/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/appsoft/iespy/beyond_limit/nopandas.py", line 280, in Thread_f
turbine_data = self.get_ls_data(time_slot)
File "/usr/appsoft/iespy/beyond_limit/nopandas.py", line 113, in get_ls_data
conn = jaydebeapi.connect(
File "/usr/local/python3.9.13/lib/python3.9/site-packages/jaydebeapi/init.py", line 412, in connect
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
File "/usr/local/python3.9.13/lib/python3.9/site-packages/jaydebeapi/init.py", line 198, in _jdbc_connect_jpype
jpype.startJVM(jvm_path, *args, ignoreUnrecognized=True,
File "/usr/local/python3.9.13/lib/python3.9/site-packages/jpype/_core.py", line 166, in startJVM
raise OSError('JVM is already started')
OSError: JVM is already started
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/appsoft/iespy/beyond_limit/nopandas.py", line 337, in
pool.starmap(run_bt, [(id,parameter_id,start_time, stop_time,normal_power,record_interval,duration,save_path,time_period_and_rate_limit_pair,logger) for id in fjid_czid_subxhid])
File "/usr/local/python3.9.13/lib/python3.9/multiprocessing/pool.py", line 372, in starmap
return self._map_async(func, iterable, starmapstar, chunksize).get()
File "/usr/local/python3.9.13/lib/python3.9/multiprocessing/pool.py", line 771, in get
raise self._value
OSError: JVM is already started

I am seeking guidance on addressing the aforementioned challenges. Additionally, are there any recommended approaches to establish multiple connections in order to enhance reading speed? PYTHON

@caiwenju
Copy link

caiwenju commented Aug 7, 2024

你好,你找到问题解决方法了吗?我看根源在于 jpype.isJVMStarted()这个方法判定可能有问题,导致后面的代码jpype.startJVM(jvm_path, *args)又执行了一次,感觉是个bug,判定没启动然后去启动,但是最终却返回已经启动。

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