IOLoop wake up trick

207 مرّات مشاهدة
التخطي إلى أول رسالة غير مقروءة

Tudor Golubenco

غير مقروءة،
23‏/09‏/2009، 5:42:18 ص23‏/9‏/2009
إلى python-...@googlegroups.com
Hi,

I was reading through the ioloop.py code and found nice the code that wakes
up the poll when it needs to stop the server. It works by sending a
character into pipe
which has one end in the poll list. However, shouldn't this fd be
registered to the READ
event instead of the WRITE event?

Like:

diff --git a/tornado/ioloop.py b/tornado/ioloop.py
index 6c4b727..15ef0b9 100644
--- a/tornado/ioloop.py
+++ b/tornado/ioloop.py
@@ -94,7 +94,7 @@ class IOLoop(object):
self._set_nonblocking(w)
self._waker_reader = os.fdopen(r, "r", 0)
self._waker_writer = os.fdopen(w, "w", 0)
- self.add_handler(r, self._read_waker, self.WRITE)
+ self.add_handler(r, self._read_waker, self.READ)

@classmethod
def instance(cls):

This is a really tiny issue because the poll timeout is set to 0.2
seconds anyway, but
wanted to point it out to make sure I understand it correctly.

Best Regards,
Tudor

--
Tudor Golubenco http://golubenco.org

Beware of bugs in the above code; I have only proved it correct,
not tried it. -- Donald Knuth

mayfield

غير مقروءة،
13‏/10‏/2009، 3:29:29 م13‏/10‏/2009
إلى Tornado Web Server
On NetBSD this change was actually necessary to make the webserver
function.

On Sep 23, 3:42 am, Tudor Golubenco <tudo...@gmail.com> wrote:
> Hi,
>
> I was reading through the ioloop.py code and found nice the code that wakes
> up thepollwhen it needs to stop the server. It works by sending a
> character into pipe
> which has one end in thepolllist. However, shouldn't this fd be
> registered to the READ
> event instead of the WRITE event?
>
> Like:
>
> diff --git a/tornado/ioloop.py b/tornado/ioloop.py
> index 6c4b727..15ef0b9 100644
> --- a/tornado/ioloop.py
> +++ b/tornado/ioloop.py
> @@ -94,7 +94,7 @@ class IOLoop(object):
>          self._set_nonblocking(w)
>          self._waker_reader = os.fdopen(r, "r", 0)
>          self._waker_writer = os.fdopen(w, "w", 0)
> -        self.add_handler(r, self._read_waker, self.WRITE)
> +        self.add_handler(r, self._read_waker, self.READ)
>
>      @classmethod
>      def instance(cls):
>
> This is a really tiny issue because thepolltimeout is set to 0.2
الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة