_jvm.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pyjvm 作者: coderforlife 项目源码 文件源码
def __start_core(prefer, opts):
    # Load the JVM dynamic library
    from ._util import jvm_load
    jvm_load(prefer)

    # Start the JVM in its own thread
    import threading, imp
    from ._internal import jvm_create
    jvm = jvm_create() # if the JVM is already created, this will raise an exception
    event = threading.Event()
    locked = imp.lock_held()
    if locked:
        # If we are in the middle of an import (which is definitely possible) we can't start
        # another thread unless we release the import lock. If we do start the thread and then wait
        # for it to start, it will deadlock Python
        imp.release_lock()
    try:
        t = threading.Thread(target=jvm.run, name='JVM-Main', args=(opts,event))
        t.daemon = True
        t.start()
        event.wait() # wait for it to be initialized
    finally:
        if locked: imp.acquire_lock()
    jvm.check_pending_exception()
    global __jvm
    __jvm = jvm
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号