##// END OF EJS Templates
allow setting identities of Manager-created sockets...
MinRK -
Show More
@@ -117,36 +117,38 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):'
117 else:
117 else:
118 return "%s://%s-%s" % (transport, ip, port)
118 return "%s://%s-%s" % (transport, ip, port)
119
119
120 def _create_connected_socket(self, channel):
120 def _create_connected_socket(self, channel, identity=None):
121 """Create a zmq Socket and connect it to the kernel."""
121 """Create a zmq Socket and connect it to the kernel."""
122 url = self._make_url(channel)
122 url = self._make_url(channel)
123 socket_type = _socket_types[channel]
123 socket_type = _socket_types[channel]
124 sock = self.context.socket(socket_type)
125 self.log.info("Connecting to: %s" % url)
124 self.log.info("Connecting to: %s" % url)
125 sock = self.context.socket(socket_type)
126 if identity:
127 sock.identity = identity
126 sock.connect(url)
128 sock.connect(url)
127 return sock
129 return sock
128
130
129 def connect_iopub(self):
131 def connect_iopub(self, identity=None):
130 """return zmq Socket connected to the IOPub channel"""
132 """return zmq Socket connected to the IOPub channel"""
131 sock = self._create_connected_socket('iopub')
133 sock = self._create_connected_socket('iopub', identity=identity)
132 sock.setsockopt(zmq.SUBSCRIBE, b'')
134 sock.setsockopt(zmq.SUBSCRIBE, b'')
133 return sock
135 return sock
134
136
135 def connect_shell(self):
137 def connect_shell(self, identity=None):
136 """return zmq Socket connected to the Shell channel"""
138 """return zmq Socket connected to the Shell channel"""
137 return self._create_connected_socket('shell')
139 return self._create_connected_socket('shell', identity=identity)
138
140
139 def connect_stdin(self):
141 def connect_stdin(self, identity=None):
140 """return zmq Socket connected to the StdIn channel"""
142 """return zmq Socket connected to the StdIn channel"""
141 return self._create_connected_socket('stdin')
143 return self._create_connected_socket('stdin', identity=identity)
142
144
143 def connect_hb(self):
145 def connect_hb(self, identity=None):
144 """return zmq Socket connected to the Heartbeat channel"""
146 """return zmq Socket connected to the Heartbeat channel"""
145 return self._create_connected_socket('hb')
147 return self._create_connected_socket('hb', identity=identity)
146
148
147 def connect_control(self):
149 def connect_control(self, identity=None):
148 """return zmq Socket connected to the Heartbeat channel"""
150 """return zmq Socket connected to the Heartbeat channel"""
149 return self._create_connected_socket('control')
151 return self._create_connected_socket('control', identity=identity)
150
152
151 #--------------------------------------------------------------------------
153 #--------------------------------------------------------------------------
152 # Kernel management
154 # Kernel management
@@ -219,13 +219,15 b' class MultiKernelManager(LoggingConfigurable):'
219 """
219 """
220
220
221 @kernel_method
221 @kernel_method
222 def connect_iopub(self, kernel_id):
222 def connect_iopub(self, kernel_id, identity=None):
223 """Return a zmq Socket connected to the iopub channel.
223 """Return a zmq Socket connected to the iopub channel.
224
224
225 Parameters
225 Parameters
226 ==========
226 ==========
227 kernel_id : uuid
227 kernel_id : uuid
228 The id of the kernel.
228 The id of the kernel
229 identity : bytes (optional)
230 The zmq identity of the socket
229
231
230 Returns
232 Returns
231 =======
233 =======
@@ -233,13 +235,15 b' class MultiKernelManager(LoggingConfigurable):'
233 """
235 """
234
236
235 @kernel_method
237 @kernel_method
236 def connect_shell(self, kernel_id):
238 def connect_shell(self, kernel_id, identity=None):
237 """Return a zmq Socket connected to the shell channel.
239 """Return a zmq Socket connected to the shell channel.
238
240
239 Parameters
241 Parameters
240 ==========
242 ==========
241 kernel_id : uuid
243 kernel_id : uuid
242 The id of the kernel.
244 The id of the kernel
245 identity : bytes (optional)
246 The zmq identity of the socket
243
247
244 Returns
248 Returns
245 =======
249 =======
@@ -247,13 +251,15 b' class MultiKernelManager(LoggingConfigurable):'
247 """
251 """
248
252
249 @kernel_method
253 @kernel_method
250 def connect_stdin(self, kernel_id):
254 def connect_stdin(self, kernel_id, identity=None):
251 """Return a zmq Socket connected to the stdin channel.
255 """Return a zmq Socket connected to the stdin channel.
252
256
253 Parameters
257 Parameters
254 ==========
258 ==========
255 kernel_id : uuid
259 kernel_id : uuid
256 The id of the kernel.
260 The id of the kernel
261 identity : bytes (optional)
262 The zmq identity of the socket
257
263
258 Returns
264 Returns
259 =======
265 =======
@@ -261,13 +267,15 b' class MultiKernelManager(LoggingConfigurable):'
261 """
267 """
262
268
263 @kernel_method
269 @kernel_method
264 def connect_hb(self, kernel_id):
270 def connect_hb(self, kernel_id, identity=None):
265 """Return a zmq Socket connected to the hb channel.
271 """Return a zmq Socket connected to the hb channel.
266
272
267 Parameters
273 Parameters
268 ==========
274 ==========
269 kernel_id : uuid
275 kernel_id : uuid
270 The id of the kernel.
276 The id of the kernel
277 identity : bytes (optional)
278 The zmq identity of the socket
271
279
272 Returns
280 Returns
273 =======
281 =======
General Comments 0
You need to be logged in to leave comments. Login now