aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorLuciano Resende <lresende@apache.org>2017-01-24 16:04:39 -0800
committerLuciano Resende <lresende@apache.org>2017-01-24 16:04:39 -0800
commit1591f422d0e286caa74add358ff6615fbeb9e6bf (patch)
tree328d9f4d1cdb8f37a5cabd89b29893a2c47e1fe9 /python
parentf39ec3fc562a080f41b52e5a7adb87974388adc4 (diff)
downloadtoree-gateway-1591f422d0e286caa74add358ff6615fbeb9e6bf.tar.gz
toree-gateway-1591f422d0e286caa74add358ff6615fbeb9e6bf.tar.bz2
toree-gateway-1591f422d0e286caa74add358ff6615fbeb9e6bf.zip
Enable running multiple notebooks concurrently
There was port conflicts starting py4j when a new notebook instance was started. We now specify the py4j ports to use in profile.json and use those to avoid conflicts.
Diffstat (limited to 'python')
-rw-r--r--python/toree_gateway_kernel.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/python/toree_gateway_kernel.py b/python/toree_gateway_kernel.py
index e9a3355..c131048 100644
--- a/python/toree_gateway_kernel.py
+++ b/python/toree_gateway_kernel.py
@@ -24,7 +24,7 @@ from os import O_NONBLOCK, read
from fcntl import fcntl, F_GETFL, F_SETFL
from subprocess import Popen, PIPE
from metakernel import MetaKernel
-from py4j.java_gateway import JavaGateway, CallbackServerParameters, java_import
+from py4j.java_gateway import JavaGateway, GatewayParameters, CallbackServerParameters, java_import
from py4j.protocol import Py4JError
from config import *
@@ -96,10 +96,15 @@ class ToreeGatewayKernel(MetaKernel):
]
self.gateway_proc = Popen(args, stderr=PIPE, stdout=PIPE)
- time.sleep(2)
+ time.sleep(5)
+
+ config = self.toreeProfile.config()
+ print('Creating py4j gateway using port:{} '.format(config['py4j_java']))
+
self.gateway = JavaGateway(
+ gateway_parameters=GatewayParameters(port=config['py4j_java']),
start_callback_server=True,
- callback_server_parameters=CallbackServerParameters())
+ callback_server_parameters=CallbackServerParameters(port=config['py4j_python']))
#flags = fcntl(self.gateway_proc.stdout, fcntl.F_GETFL) # get current p.stdout flags
#fcntl(self.gateway_proc.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)