##// END OF EJS Templates
Fix iopubwatcher example script.
Blake Griffith -
Show More
@@ -14,35 +14,29 b' Authors'
14 14 * MinRK
15 15 """
16 16
17 import os
18 17 import sys
19 18 import json
20 19 import zmq
21 20
22 21 from IPython.kernel.zmq.session import Session
23 from IPython.parallel.util import disambiguate_url
24 22 from IPython.utils.py3compat import str_to_bytes
25 23 from IPython.utils.path import get_security_file
26 24
27 25 def main(connection_file):
28 26 """watch iopub channel, and print messages"""
29
27
30 28 ctx = zmq.Context.instance()
31
29
32 30 with open(connection_file) as f:
33 31 cfg = json.loads(f.read())
34
35 location = cfg['location']
36 reg_url = cfg['url']
37 session = Session(key=str_to_bytes(cfg['exec_key']))
38
39 query = ctx.socket(zmq.DEALER)
40 query.connect(disambiguate_url(cfg['url'], location))
41 session.send(query, "connection_request")
42 idents,msg = session.recv(query, mode=0)
43 c = msg['content']
44 iopub_url = disambiguate_url(c['iopub'], location)
32
33 reg_url = cfg['interface']
34 iopub_port = cfg['iopub']
35 iopub_url = "%s:%s"%(reg_url, iopub_port)
36
37 session = Session(key=str_to_bytes(cfg['key']))
45 38 sub = ctx.socket(zmq.SUB)
39
46 40 # This will subscribe to all messages:
47 41 sub.setsockopt(zmq.SUBSCRIBE, b'')
48 42 # replace with b'' with b'engine.1.stdout' to subscribe only to engine 1's stdout
General Comments 0
You need to be logged in to leave comments. Login now