From 130040a889fcab54fe6e72e0bba41f5fa6f0e091 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Wed, 23 Feb 2011 17:15:36 -0800 Subject: [PATCH] Python3 fixes in IOLoop * __lt__ instead of __cmp__ * Write bytes instead of str to waker pipe * Reading from the waker pipe returns '' at EOF instead of raising error --- tornado/ioloop.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 62b2b0900..d4bec01a1 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -25,6 +25,7 @@ import time import traceback from tornado import stack_context +from tornado.escape import utf8 try: import signal @@ -335,7 +336,7 @@ class IOLoop(object): def _wake(self): try: - self._waker_writer.write("x") + self._waker_writer.write(utf8("x")) except IOError: pass @@ -362,7 +363,8 @@ class IOLoop(object): def _read_waker(self, fd, events): try: while True: - self._waker_reader.read() + result = self._waker_reader.read() + if not result: break except IOError: pass @@ -385,9 +387,9 @@ class _Timeout(object): self.deadline = deadline self.callback = callback - def __cmp__(self, other): - return cmp((self.deadline, id(self.callback)), - (other.deadline, id(other.callback))) + def __lt__(self, other): + return ((self.deadline, id(self.callback)) < + (other.deadline, id(other.callback))) class PeriodicCallback(object): -- 2.47.3