Add a shutdown hook for pslpython to stop the JVM.
@@ -16,6 +16,7 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
+import atexit
import json
import os
import sys
@@ -40,7 +41,9 @@ def ground(config, base_path = '.', jvm_options = []):
raw_output = GroundingAPI.serializedGround(json.dumps(config), base_path)
return json.loads(str(raw_output))
+@atexit.register
def _shutdown():
+ if (jpype.isJVMStarted()):
jpype.shutdownJVM()
def _init(jvm_options = []):
