From: Ben Darnell Date: Tue, 3 Jan 2012 03:17:57 +0000 (-0800) Subject: Add comment about (non-)thread-safety of IOLoop.add_timeout. X-Git-Tag: v2.2.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffa8f152ab9ec479ed2721581a8f088983a9ba8b;p=thirdparty%2Ftornado.git Add comment about (non-)thread-safety of IOLoop.add_timeout. --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 4ed638e7e..edd2fec2e 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -352,6 +352,10 @@ class IOLoop(object): ``deadline`` may be a number denoting a unix timestamp (as returned by ``time.time()`` or a ``datetime.timedelta`` object for a deadline relative to the current time. + + Note that it is not safe to call `add_timeout` from other threads. + Instead, you must use `add_callback` to transfer control to the + IOLoop's thread, and then call `add_timeout` from there. """ timeout = _Timeout(deadline, stack_context.wrap(callback)) heapq.heappush(self._timeouts, timeout)