From: Ben Darnell Date: Thu, 24 Feb 2011 01:15:36 +0000 (-0800) Subject: Python3 fixes in IOLoop X-Git-Tag: v2.0.0~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=130040a889fcab54fe6e72e0bba41f5fa6f0e091;p=thirdparty%2Ftornado.git 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 --- 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):