123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
|
def start(self): if self._running: raise RuntimeError(\”IOLoop is already running\”) self._setup_logging() if self._stopped: self._stopped = False return old_current = getattr(IOLoop._current, \”instance\”, None) IOLoop._current.instance = self self._thread_ident = thread.get_ident() self._running = True old_wakeup_fd = None if hasattr(signal, \’set_wakeup_fd\’) and os.name == \’posix\’: try: old_wakeup_fd = signal.set_wakeup_fd(self._waker.write_fileno()) if old_wakeup_fd != –y\”>)) if old_wakeup_fd != –rayon-toolbar\” data-settings=\” show\” style=\”font-size: 13px !important;height: 19.5px !important; line-height: 19.5px !important;\”>
1234
|
最近闲暇无事,阅读了一下tornado的源码,对整体的结构有了初步认识,与大家分享不知道为什么右边的目录一直出不来,非常不舒服.不如移步到oschina吧....[http://my.oschina.net/abc2001x/blog/476349][1] |
ioloop
12
|
`ioloop`是`tornado`的核心模块,也是个调度模块,各种异步事件都是由他调度的,所以必须弄清他的执行逻辑 |
源码分析
12
|
而`ioloop`的核心部分则是 `while True`这个循环内部的逻辑,贴上他的代码如下 |
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
|
def start(self): if self._running: raise RuntimeError(\”IOLoop is already running\”) self._setup_logging() if self._stopped: self._stopped = False return old_current = getattr(IOLoop._current, \”instance\”, None) IOLoop._current.instance = self self._thread_ident = thread.get_ident() self._running = True old_wakeup_fd = None if hasattr(signal, \’set_wakeup_fd\’) and os.name == \’posix\’: try: old_wakeup_fd = signal.set_wakeup_fd(self._waker.write_fileno()) if old_wakeup_fd != –n\”>1: signal.set_wakeup_fd(old_wakeup_fd) |
|