Begins watching source files for changes.

    .. versionchanged:: 5.0
       The ``io_loop`` argument (deprecated since version 4.1) has been removed.
776721
def start(check_time: int = 500) -> None:
    
    io_loop = ioloop.IOLoop.current()
    if io_loop in _io_loops:
        return
    _io_loops[io_loop] = True
    if len(_io_loops) > 1:
        gen_log.warning("tornado.autoreload started more than once in the same process")
    modify_times = {}  # type: Dict[str, float]
    callback = functools.partial(_reload_on_update, modify_times)
    scheduler = ioloop.PeriodicCallback(callback, check_time)
    scheduler.start()
485969
private void monitorForChanges() {
        if (monitorRunning) {
            return;
        }

        final Path path;
        try {
            path = Paths.get(configPath);
        } catch (final Exception e) {
            LOGGER.warn("Cannot monitor configuration {}, disabling monitoring; {}", configPath, e.getMessage());
            return;
        }

        if (!path.toFile().exists()) {
            LOGGER.debug("Configuration {} does not exist, disabling monitoring", configPath);
            return;
        }
        final Path directoryPath = path.getParent();

        try {
            final WatchService watchService = FileSystems.getDefault().newWatchService();
            directoryPath.register(watchService, ENTRY_MODIFY);

            monitorThread = new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        for (;;) {
                            final WatchKey key;
                            try {
                                key = watchService.take();
                            } catch (final InterruptedException e) {
                                LOGGER.debug("Interrupted the configuration monitor thread.");
                                break;
                            }

                            for (final WatchEvent<?> event : key.pollEvents()) {
                                final WatchEvent.Kind<?> kind = event.kind();
                                if (kind == OVERFLOW) {
                                    continue;
                                }

                                // If the configuration file triggered this event, reload it
                                final Path changed = (Path) event.context();
                                if (changed.equals(path.getFileName())) {
                                    LOGGER.info(
                                            "Configuration {} has been updated, reloading.",
                                            path);
                                    try {
                                        loadConfiguration();
                                    } catch (final IOException e) {
                                        LOGGER.error("Failed to reload configuration {}", configPath, e);
                                    }
                                }

                                // reset the key
                                final boolean valid = key.reset();
                                if (!valid) {
                                    LOGGER.debug("Monitor of {} is no longer valid", path);
                                    break;
                                }
                            }
                        }
                    } finally {
                        try {
                            watchService.close();
                        } catch (final IOException e) {
                            LOGGER.error("Failed to stop configuration monitor", e);
                        }
                    }
                    monitorRunning = false;
                }
            });
        } catch (final IOException e) {
            LOGGER.error("Failed to start configuration monitor", e);
        }

        monitorThread.start();
        monitorRunning = true;
    }
1082367
@Deprecated
    public void stopWatching(File file) {
        if (file == null) {
            throw new IllegalArgumentException("Null file argument");
        }
        synchronized (mutex) {
            stopWatchingInternal(file.toPath());
        }
    }
1265364
def main():
    """"""
    from docopt import docopt; arguments = docopt(__doc__, version=package.title() + " v" + version)
    global verbose
    verbose = arguments['--verbose']

    if verbose:
	print("target folder: " + target_folder + " (" + project_path +"/" + target_folder + ")")

    if arguments['init']:
	init_current_directory()

    if arguments['build']:
	if arguments['<file>']:
	    buildFile(arguments['<file>'])
	else:
	    buildAll()

    if arguments['watch']:
	if verbose:
	    print("Watching " + project_path)
        import time
	from watchdog.observers import Observer
	event_handler = MyWatchHandler()
	observer = Observer()
	observer.schedule(event_handler, project_path, recursive=True)
	observer.start()
	try:
	    while True:
	        time.sleep(1)
	except KeyboardInterrupt:
	    observer.stop()
	observer.join()

    if arguments['clean']:
	clean()
1097438
def current_ioloop(io_loop):
    '''
    
    '''
    orig_loop = tornado.ioloop.IOLoop.current()
    io_loop.make_current()
    try:
        yield
    finally:
        orig_loop.make_current()
107610
function watchjs(sources, outdir, outfile, opt_options) {
  var bundler = watchify(browserify({
    entries: sources,
    debug: false,
    // Watchify options:
    cache: {},
    packageCache: {},
    fullPaths: true
  }));

  bundler.on('update', function() {
    gutil.log('recompiling js...');
    rebundle_(bundler, outdir, outfile, opt_options);
    gutil.log('finished recompiling js');
  });
  return rebundle_(bundler, outdir, outfile, opt_options);
}
388967
@Deprecated
    public void weakAddWatcher(Path file, Watcher watcher) {
        weakAddWatcher(file, (Listener) watcher);
    }
348510
def jiggle_source_code(self):  # type: () ->int
        
        changed = 0
        for file_name in self.file_inventory.source_files:
            to_write = []
            # self.create_missing(file_name, file_name)
            if not os.path.isfile(file_name):
                continue

            all_source = self.file_opener.read_this(file_name)
            if "__version_info__" in all_source:
                logger.warning("We have __version_info__ to sync up.")
                # raise TypeError()

            with self.file_opener.open_this(file_name, "r") as infile:
                for line in infile:
                    leading_white = self.leading_whitespace(line)
                    version, version_token = dunder_version.find_in_line(line)
                    if version:
                        simplified_line = dunder_version.simplify_line(
                            line, keep_comma=True
                        )
                        if simplified_line.strip(" \t\n").endswith(","):
                            comma = ","
                        else:
                            comma = ""

                        if simplified_line.strip(" \t\n").startswith(","):
                            start_comma = ","
                        else:
                            start_comma = ""

                        to_write.append(
                            '{0}{1}{2} = "{3}"{4}{5}\n'.format(
                                start_comma,
                                leading_white,
                                version_token,
                                unicode(self.version_to_write()),
                                comma,
                                self.signature,
                            )
                        )
                    else:
                        to_write.append(line)

            check(self.file_opener.open_this(file_name, "r").read(), "".join(to_write))
            with open(file_name, "w") as outfile:
                outfile.writelines(to_write)
                changed += 1
        return changed
1157239
function(file, event) {
    var fn = function(file) {};
    for(var i = 0; i < watchList.length; i++) {
        if(watchList[i].file === file) {
            watchers[i].on(event, fn);
            watchList[i].callback[event] = fn;
            return;
        }
    }
    throw new Error(file + " was not being watched previously");
}
1286864
function watch(sourcePath, patterns, commands) {
  var isBusy = false;
  var isPending = false;
  var runnable = function() {
    if (isBusy) return (isPending = true);
    isBusy = true;
    run(commands, function(err) {
      if (err) console.error(err.stack || err);
      isBusy = false;
      if (isPending) runnable(isPending = false);
    });
  };
  chokidar.watch(patterns, {
    cwd: sourcePath,
    ignoreInitial: true
  }).on('add', runnable).on('change', runnable).on('unlink', runnable);
}
509802
def wait_in_ioloop
      raise LightIO::Error, "Watchers::IO can't cross threads" if @ioloop != LightIO::Core::IOloop.current
      raise EOFError, "can't wait closed IO watcher" if @monitor.closed?
      @ioloop.wait(self)
    end
403677
def start(self, io_loop):
        
        for callback in self.before_run_callbacks:
            try:
                callback(self.tornado_application, io_loop)
            except Exception:
                self.logger.error('before_run callback %r cancelled start',
                                  callback, exc_info=1)
                self.stop(io_loop)
                raise

        for callback in self.on_start_callbacks:
            io_loop.spawn_callback(callback, self.tornado_application, io_loop)
1271801
def _from_io(self, source: IO):
        
        read = source.read

        if unpack('>I', source.read(4))[0] != ClassFile.MAGIC:
            raise ValueError('invalid magic number')

        # The version is swapped on disk to (minor, major), so swap it back.
        self.version = unpack('>HH', source.read(4))[::-1]

        self._constants.unpack(source)

        # ClassFile access_flags, see section #4.1 of the JVM specs.
        self.access_flags.unpack(read(2))

        # The CONSTANT_Class indexes for "this" class and its superclass.
        # Interfaces are a simple list of CONSTANT_Class indexes.
        self._this, self._super, interfaces_count = unpack('>HHH', read(6))
        self._interfaces = unpack(
            f'>{interfaces_count}H',
            read(2 * interfaces_count)
        )

        self.fields.unpack(source)
        self.methods.unpack(source)
        self.attributes.unpack(source)
452787
def restore_watched(plex, opts):
    
    with open(opts.filepath, 'r') as handle:
        source = json.load(handle)
    # Find the differences
    differences = defaultdict(lambda: dict())
    for section in _iter_sections(plex, opts):
        print('Finding differences in %s..' % section.title)
        skey = section.title.lower()
        for item in _iter_items(section):
            ikey = _item_key(item)
            sval = source.get(skey,{}).get(ikey)
            if sval is None:
                raise SystemExit('%s not found' % ikey)
            if (sval is not None and item.isWatched != sval) and (not opts.watchedonly or sval):
                differences[skey][ikey] = {'isWatched':sval, 'item':item}
    print('Applying %s differences to destination' % len(differences))
    import pprint; pprint.pprint(differences)
644290
public synchronized boolean handleChangedFile(ChangedFile changedFile) {
        File watchDir = getWatchDir(changedFile.getFile());
        SyncWorker worker = new SyncWorker(changedFile, watchDir, endpoint);

        try {
            addToWorkerList(worker);
            workerPool.execute(worker);
            return true;
        } catch (RejectedExecutionException e) {
            workerList.remove(worker);
            return false;
        }
    }
642377
def watchable_args #:nodoc:
      files, dirs = config.watchable_files.dup, config.watchable_dirs.dup

      ActiveSupport::Dependencies.autoload_paths.each do |path|
        dirs[path.to_s] = [:rb]
      end

      [files, dirs]
    end
1007533
function(data) {
            var mode = bs.options.get("mode");
            var open = bs.options.get("open");

            if (
                mode === "proxy" ||
                mode === "server" ||
                open === "ui" ||
                open === "ui-external"
            ) {
                utils.openBrowser(data.url, bs.options, bs);
            }

            // log about any file watching
            if (bs.watchers) {
                bs.events.emit("file:watching", bs.watchers);
            }
        }