def watch_tasks(self): changes = Task.watch() if not changes: return if time.time() - self._last_reload_time < 3: # if you changed lot of files in one time # it will refresh too many times logging.info('ignore this reload action') return logging.info('Reload %s waiters', len(self.waiters)) msg = { 'command': 'reload', 'path': Task.last_modified or '*', 'liveCSS': True } self._last_reload_time = time.time() for waiter in LiveReloadHandler.waiters: try: waiter.write_message(msg) except: logging.error('Error sending message', exc_info=True) LiveReloadHandler.waiters.remove(waiter)
def watch_tasks(self): changes = Task.watch() if not changes: return if time.time() - self._last_reload_time < 3: # if you changed lot of files in one time # it will refresh too many times logging.info('ignore this reload action') return post_funcs = Task.tasks.get('post') if post_funcs: [func() for func in post_funcs if callable(func)] Task.current_position = 0 logging.info('Reload %s waiters', len(self.waiters)) msg = { 'command': 'reload', 'path': Task.last_modified or '*', 'liveCSS': True } self._last_reload_time = time.time() for waiter in LiveReloadHandler.waiters: try: waiter.write_message(msg) except: logging.error('Error sending message', exc_info=True) LiveReloadHandler.waiters.remove(waiter)
def watch_tasks(self): changes = Task.watch() if not changes: return if time.time() - self._last_reload_time < 3: # if you changed lot of files in one time # it will refresh too many times logging.info('ignore this reload action') return logging.info('Reload %s waiters', len(self.waiters)) msg = { 'command': 'reload', 'path': '*', 'liveCSS': True } self._last_reload_time = time.time() for waiter in LiveReloadHandler.waiters: try: waiter.write_message(msg) except: logging.error('Error sending message', exc_info=True) LiveReloadHandler.waiters.remove(waiter)
def main(): if len(sys.argv) > 1: #: command-line tools like Makefile execfile('Guardfile') for cmd in sys.argv[1:]: print(cmd) exec('%s()' % cmd) return #: option config is not available #: but this enables pretty colorful logging tornado.options.parse_command_line() app = tornado.web.Application(handlers=handlers) app.listen(35729) #: task watch initialize Task.watch() print('Start service at 127.0.0.1:35729') tornado.ioloop.IOLoop.instance().start()
def watch_tasks(self): changes = Task.watch() if not changes: return logging.info("Reload %s waiters" "\nChanged %s" % (len(LiveReloadHandler.waiters), changes)) msg = {"command": "reload", "path": "*", "liveCSS": True} for waiter in LiveReloadHandler.waiters: try: waiter.write_message(msg) except: logging.error("Error sending message", exc_info=True) LiveReloadHandler.waiters.remove(waiter)
def watch_tasks(self): changes = Task.watch() if not changes: return logging.info('Reload %s waiters' '\nChanged %s' % (len(LiveReloadHandler.waiters), changes)) msg = {'command': 'reload', 'path': '*', 'liveCSS': True} for waiter in LiveReloadHandler.waiters: try: waiter.write_message(msg) except: logging.error('Error sending message', exc_info=True) LiveReloadHandler.waiters.remove(waiter)
def watch_tasks(self): changes = Task.watch() if changes: send_notify( 'Reload %s waiters' '\nChanged %s' % (len(LiveReloadHandler.waiters), changes) ) msg = { 'command': 'reload', 'path': '*', 'liveCSS': True } for waiter in LiveReloadHandler.waiters: try: waiter.write_message(msg) except: logging.error('Error sending message', exc_info=True) LiveReloadHandler.waiters.remove(waiter)
def watch_tasks(self): changes = Task.watch() if not changes: return if time.time() - self._last_reload_time < 3: # if you changed lot of files in one time # it will refresh too many times logging.info("ignore this reload action") return logging.info("Reload %s waiters", len(self.waiters)) msg = {"command": "reload", "path": "*", "liveCSS": True} self._last_reload_time = time.time() for waiter in LiveReloadHandler.waiters: try: waiter.write_message(msg) except: logging.error("Error sending message", exc_info=True) LiveReloadHandler.waiters.remove(waiter)
def poll_tasks(self): changes = Task.watch() if not changes: return self.watch_tasks()