Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

use print_function

  • Loading branch information...
commit 77b4226c7ed903485f4310c677965ffa1834f514 1 parent d405cd6
@minrk minrk authored
View
6 IPython/zmq/parallel/client.py
@@ -10,6 +10,8 @@
# Imports
#-----------------------------------------------------------------------------
+from __future__ import print_function
+
import time
from pprint import pprint
@@ -245,7 +247,7 @@ def _handle_execute_reply(self, msg):
parent = msg['parent_header']
msg_id = parent['msg_id']
if msg_id not in self.outstanding:
- print "got unknown result: %s"%msg_id
+ print("got unknown result: %s"%msg_id)
else:
self.outstanding.remove(msg_id)
self.results[msg_id] = ss.unwrap_exception(msg['content'])
@@ -256,7 +258,7 @@ def _handle_apply_reply(self, msg):
parent = msg['parent_header']
msg_id = parent['msg_id']
if msg_id not in self.outstanding:
- print "got unknown result: %s"%msg_id
+ print ("got unknown result: %s"%msg_id)
else:
self.outstanding.remove(msg_id)
content = msg['content']
View
2  IPython/zmq/parallel/dependency.py
@@ -14,7 +14,6 @@ class UnmetDependency(Exception):
class depend2(object):
"""dependency decorator"""
def __init__(self, f, *args, **kwargs):
- print "Inside __init__()"
self.dependency = (f,args,kwargs)
def __call__(self, f, *args, **kwargs):
@@ -24,7 +23,6 @@ def __call__(self, f, *args, **kwargs):
class depend(object):
"""Dependency decorator, for use with tasks."""
def __init__(self, f, *args, **kwargs):
- print "Inside __init__()"
self.f = f
self.args = args
self.kwargs = kwargs
View
3  IPython/zmq/parallel/heartmonitor.py
@@ -4,6 +4,7 @@
and hearts are tracked based on their XREQ identities.
"""
+from __future__ import print_function
import time
import uuid
@@ -130,7 +131,7 @@ def handle_heart_failure(self, heart):
try:
handler(heart)
except Exception, e:
- print e
+ print (e)
logger.error("heartbeat::Bad Handler! %s"%handler)
pass
else:
View
7 IPython/zmq/parallel/scheduler.py
@@ -2,6 +2,7 @@
# Imports
#----------------------------------------------------------------------
+from __future__ import print_function
from random import randint,random
try:
@@ -268,7 +269,7 @@ def save_unmet(self, msg_id, msg, after, follow):
self.depending[msg_id] = (msg_id,msg,after,follow)
# track the ids in both follow/after, but not those already completed
for dep_id in after.union(follow).difference(self.all_done):
- print dep_id
+ print (dep_id)
if dep_id not in self.dependencies:
self.dependencies[dep_id] = set()
self.dependencies[dep_id].add(msg_id)
@@ -284,7 +285,7 @@ def submit_task(self, msg_id, msg, follow=None, indices=None):
if indices:
idx = indices[idx]
target = self.targets[idx]
- print target, map(str, msg[:3])
+ print (target, map(str, msg[:3]))
self.engine_stream.send(target, flags=zmq.SNDMORE, copy=False)
self.engine_stream.send_multipart(msg, copy=False)
self.add_job(idx)
@@ -316,7 +317,7 @@ def handle_result_success(self, idents, parent, raw_msg):
client = idents[1]
# swap_ids for XREP-XREP mirror
raw_msg[:2] = [client,engine]
- print map(str, raw_msg[:4])
+ print (map(str, raw_msg[:4]))
self.client_stream.send_multipart(raw_msg, copy=False)
# now, update our data structures
msg_id = parent['msg_id']
View
31 IPython/zmq/parallel/streamkernel.py
@@ -3,6 +3,7 @@
Kernel adapted from kernel.py to use ZMQ Streams
"""
+from __future__ import print_function
import __builtin__
import os
import sys
@@ -183,8 +184,8 @@ def abort_queue(self, stream):
# assert self.reply_socketly_socket.rcvmore(), "Unexpected missing message part."
# msg = self.reply_socket.recv_json()
- print>>sys.__stdout__, "Aborting:"
- print>>sys.__stdout__, Message(msg)
+ print ("Aborting:", file=sys.__stdout__)
+ print (Message(msg), file=sys.__stdout__)
msg_type = msg['msg_type']
reply_type = msg_type.split('_')[0] + '_reply'
# reply_msg = self.session.msg(reply_type, {'status' : 'aborted'}, msg)
@@ -192,7 +193,7 @@ def abort_queue(self, stream):
# self.reply_socket.send_json(reply_msg)
reply_msg = self.session.send(stream, reply_type,
content={'status' : 'aborted'}, parent=msg, ident=idents)[0]
- print>>sys.__stdout__, Message(reply_msg)
+ print(Message(reply_msg), file=sys.__stdout__)
# We need to wait a bit for requests to come in. This can probably
# be set shorter for true asynchronous clients.
time.sleep(0.05)
@@ -210,7 +211,7 @@ def abort_request(self, stream, ident, parent):
content = dict(status='ok')
reply_msg = self.session.send(stream, 'abort_reply', content=content,
parent=parent, ident=ident)[0]
- print>>sys.__stdout__, Message(reply_msg)
+ print(Message(reply_msg), file=sys.__stdout__)
def kill_request(self, stream, idents, parent):
"""kill ourselves. This should really be handled in an external process"""
@@ -233,7 +234,7 @@ def dispatch_control(self, msg):
handler = self.control_handlers.get(msg['msg_type'], None)
if handler is None:
- print >> sys.__stderr__, "UNKNOWN CONTROL MESSAGE TYPE:", msg
+ print ("UNKNOWN CONTROL MESSAGE TYPE:", msg, file=sys.__stderr__)
else:
handler(self.control_stream, idents, msg)
@@ -281,8 +282,8 @@ def execute_request(self, stream, ident, parent):
try:
code = parent[u'content'][u'code']
except:
- print>>sys.__stderr__, "Got bad msg: "
- print>>sys.__stderr__, Message(parent)
+ print("Got bad msg: ", file=sys.__stderr__)
+ print(Message(parent), file=sys.__stderr__)
return
# pyin_msg = self.session.msg(u'pyin',{u'code':code}, parent=parent)
# self.pub_stream.send(pyin_msg)
@@ -312,7 +313,7 @@ def execute_request(self, stream, ident, parent):
# self.reply_socket.send(ident, zmq.SNDMORE)
# self.reply_socket.send_json(reply_msg)
reply_msg = self.session.send(stream, u'execute_reply', reply_content, parent=parent, ident=ident)
- print>>sys.__stdout__, Message(reply_msg)
+ print(Message(reply_msg), file=sys.__stdout__)
if reply_msg['content']['status'] == u'error':
self.abort_queues()
@@ -327,15 +328,15 @@ def complete(self, msg):
return self.completer.complete(msg.content.line, msg.content.text)
def apply_request(self, stream, ident, parent):
- print parent
+ print (parent)
try:
content = parent[u'content']
bufs = parent[u'buffers']
msg_id = parent['header']['msg_id']
bound = content.get('bound', False)
except:
- print>>sys.__stderr__, "Got bad msg: "
- print>>sys.__stderr__, Message(parent)
+ print("Got bad msg: ", file=sys.__stderr__)
+ print(Message(parent), file=sys.__stderr__)
return
# pyin_msg = self.session.msg(u'pyin',{u'code':code}, parent=parent)
# self.pub_stream.send(pyin_msg)
@@ -400,7 +401,7 @@ def apply_request(self, stream, ident, parent):
# self.reply_socket.send_json(reply_msg)
reply_msg = self.session.send(stream, u'apply_reply', reply_content,
parent=parent, ident=ident,buffers=result_buf, subheader=sub)
- print>>sys.__stdout__, Message(reply_msg)
+ print(Message(reply_msg), file=sys.__stdout__)
# if reply_msg['content']['status'] == u'error':
# self.abort_queues()
@@ -420,7 +421,7 @@ def dispatch_queue(self, stream, msg):
return
handler = self.queue_handlers.get(msg['msg_type'], None)
if handler is None:
- print >> sys.__stderr__, "UNKNOWN MESSAGE TYPE:", msg
+ print ("UNKNOWN MESSAGE TYPE:", msg, file=sys.__stderr__)
else:
handler(stream, idents, msg)
@@ -471,7 +472,7 @@ def main():
rep_conn = connection % port_base
pub_conn = connection % (port_base+1)
- print >>sys.__stdout__, "Starting the kernel..."
+ print("Starting the kernel...", file=sys.__stdout__)
# print >>sys.__stdout__, "XREQ Channel:", rep_conn
# print >>sys.__stdout__, "PUB Channel:", pub_conn
@@ -499,7 +500,7 @@ def main():
kernel.user_ns['sleep'] = time.sleep
kernel.user_ns['s'] = 'Test string'
- print >>sys.__stdout__, "Use Ctrl-\\ (NOT Ctrl-C!) to terminate."
+ print ("Use Ctrl-\\ (NOT Ctrl-C!) to terminate.", file=sys.__stdout__)
kernel.start()
loop.start()
View
2  IPython/zmq/parallel/streamsession.py
@@ -413,7 +413,7 @@ def recv(self, socket, mode=zmq.NOBLOCK, content=True, copy=True):
try:
return idents, self.unpack_message(msg, content=content, copy=copy)
except Exception, e:
- print idents, msg
+ print (idents, msg)
# TODO: handle it
raise e
Please sign in to comment.
Something went wrong with that request. Please try again.