'A scheduled task that checks for timeout.'

@attach_runtime_statistics(u'{0.__class__.__name__}.{function_name}')
def _task_check_timeout(self):

    if (not self._is_running):
        return
    need_session_cleanup = False
    for (key, session) in self._session_dict.items():
        if self._check_session_timeout(session):
            need_session_cleanup = True
            self._logger.info(u'%s    timed    out', session)
            if session.failure_callback:
                callback = (lambda cb=session.failure_callback, addr=session.address, fn=session.file_name, msg='timeout', ei=session.extra_info: cb(addr, fn, msg, ei))
                self._callbacks.append(callback)
            self._cleanup_session(key)
    if need_session_cleanup:
        self._schedule_callback_processing()
