Add a path in watch queue
420915
def add_handler(self, path, handler):
        
        self.signatures[path] = self.get_path_signature(path)
        self.handlers[path] = handler
1108817
function watch (glob, watchOpt) {
    if (!started) {
      deferredWatch = emitter.watch.bind(null, glob, watchOpt)
    } else {
      // destroy previous
      if (fileWatcher) fileWatcher.close()
      glob = glob && glob.length > 0 ? glob : defaultWatchGlob
      glob = Array.isArray(glob) ? glob : [ glob ]
      watchOpt = xtend({ poll: opts.poll }, watchOpt)

      fileWatcher = createFileWatch(glob, watchOpt)
      fileWatcher.on('watch', emitter.emit.bind(emitter, 'watch'))
    }
    return emitter
  }
873654
public function addToWatchFolders($path, $watch_folders)
    {
        collect($watch_folders)->each(function ($folder) use ($path) {
            $this->watchFolders[] = !file_exists($new = make_path([$path, $folder])) && file_exists($folder)
                ? $folder
                : $new;
        });
    }
1246853
def child_watch_add(*args, **kwargs):
    """"""
    priority, pid, function, data = _child_watch_add_get_args(*args, **kwargs)
    return GLib.
1742
function processWatches(items) {
  // queue up matches
  // { "member" : { "uri" : [ "match", "match" ] } }
  var toSend = {};
  GLOBAL.svc.indexer.retrieveWatches({}, function(err, res) {
    if (res.hits) {
      var watches = _.pluck(res.hits.hits, '_source');
      // for each hit
      items.forEach(function(item) {
        var matches = watchLib.matches(item, watches);
        if (matches.length) {
          matches.forEach(function(match) {
            toSend[match.member] = toSend[match.member] || {};
            toSend[match.member][item.uri] = toSend[match.member][item.uri] || [];
            toSend[match.member][item.uri].push(match.match);
          });
        }
      });
      send(toSend);
    }
  });
}
547157
public static WatchMonitor createModify(Path path, int maxDepth, Watcher watcher) {
		final WatchMonitor watchMonitor = create(path, maxDepth, WatchMonitor.ENTRY_MODIFY);
		watchMonitor.setWatcher(watcher);
		return watchMonitor;
	}
791275
function watch(watchOptions) {

      var watcher = chokidar.watch(watchOptions.dirs, {
        ignoreInitial: true,
        ignored: /[/\\]\./
      });

      watcher.on('add', function(pathFile) {
        onWatcher(pathFile);
      });

      watcher.on('change', function(pathFile) {
        onWatcher(pathFile);
      });

      watcher.on('unlink', function(pathFile) {
        onWatcher(pathFile);
      });

      var updating = false;
      var queued = null;

      function onWatcher(pathFile) {

        if (updating) {
          queued = pathFile;
          return;
        }

        queued = null;
        updating = true;

        return Promise.resolve()
          .then(function() {
            return watchOptions.onFile(pathFile);
          })
          .then(function() {
            return Promise.delay(1000);
          })
          .then(function() {
            updating = false;
            if (queued) {
              return onWatcher(queued);
            }
          });
      }
    }
129226
def activate_watch(self, watch_id, params=None):
        
        if watch_id in SKIP_IN_PATH:
            raise ValueError("Empty value passed for a required argument 'watch_id'.")
        return self.transport.perform_request(
            "PUT", _make_path("_watcher", "watch", watch_id, "_activate"), params=params
        )
294772
function watchAdditional(browserify, options) {
	var changingDeps = {};
	var pending = false;
	var updating = false;

	// watchify and sharing
	var sharedCache = browserify._options.cache;
	var sharedPkgcache = browserify._options.packageCache;

	var cache_target_paths = {};
	var mcached = new mutils.Cached(browserify);

	// watchfiles in watchify
	var watchify_on_files = {};
	browserify.on('bundle', function () {
		watchify_on_files = {};
	});
	browserify.on('file', function (file) {
		// NOTE : collect watch files of watchify
		watchify_on_files[file] = true;
	});

	browserify.on('bundle', function(bundle) {
		updating = true;

		var watched = false,
			ended = false;

		// NOTE : wait until browserify._recorded is update, for when used with the default options.
		var stream = through.obj(
			function transform(row, enc, next) { this.push(row); next(); }, // no-op
			function flush(done) {
				if (checkWatchify(browserify)) {
					var full_paths = mutils.toResolvePaths([].concat(options.files).concat(options.getFiles()));

					// add require target files
					mcached.collectRequirePaths(full_paths, function (collect_file_sources) {
						var collect_full_paths = Object.keys(collect_file_sources);
						// NOTE : keep wildcard path
						watchFile(_.uniq(full_paths.concat(collect_full_paths)));

						watched = true;
						oncomplete();
					});
				} else {
					watched = true;
				}
				done();
			});
		browserify.pipeline.get('record').push(stream);

		bundle.on('error', onend);
		bundle.on('end', onend);
		function onend () {
			ended = true;
			oncomplete();
		}

		function oncomplete () {
			if (!watched || !ended) return;

			if (checkWatchify(browserify)) {
				// unwatch the duplicated files from watchify
				var target_paths = _.uniq(
					Object.keys(browserify.pipeline.get('deps')._streams[0].visited)
						.concat(Object.keys(watchify_on_files)));

				unwatch(target_paths);
				target_paths.forEach(function (path) {
					cache_target_paths[path] = true;
				});
			}

			updating = false;
		}
	});


	var w = null;
	var runner = null;

	function watchFile(paths) {
		if (w) w.close();

		// TODO : support ignored

		w = chokidar.watch(paths);
		w.setMaxListeners(0);
		w.on('error', browserify.emit.bind(browserify, 'error'));
		w.on('change', function (file) {
			invalidate(file);
		});

		runner = new DelayRunner(DELAY);
	}

	function invalidate(id) {
		if (sharedCache) delete sharedCache[id];
		if (sharedPkgcache) delete sharedPkgcache[id];
		changingDeps[id] = true;

		var emit = true;
		emit = emit && !cache_target_paths[id];
		emit = emit && _.every(watchify_on_files, function (dummy, file) { return !putils.isEqualPath(id, file); });

		if (!updating && cache_target_paths[id]) {
			// remove expired path
			delete cache_target_paths[id];
		}

		if (emit) {
			// wait for the disk/editor to quiet down first:
			if (pending) clearTimeout(pending);
			pending = setTimeout(notify, DELAY);
		}
	}

	function notify() {
		if (updating) {
			pending = setTimeout(notify, DELAY);
		} else {
			pending = false;
			browserify.emit('update', Object.keys(changingDeps));
			changingDeps = {};
		}
	}

	function unwatch(paths) {
		// NOTE : do not work w.unwatch, if after immediate add.
		//        make a delay so
		runner.run(function () { w.unwatch(paths); });
	}

	function checkWatchify(browserify) {
		// XXX : _watcher is private field. judgement using watchify is not appropriate.
		//       but only this one :(
		return !!browserify._watcher;
	}

	return browserify;
}
1186909
function add(path, callback, context){
    var route = get({
      path: path,
      autocreate: true
    });

    route.callbacks_.push({
      cb_: callback,
      context: context,
      callback: typeof callback != 'function' ? callback || {} : {
        match: callback
      }
    });

    initSchedule.add(route);

    return route;
  }
1114651
def add_watched_directory(self, dir_path):
    
    req = ApiWatchedDir(self._get_resource_root(), path=dir_path)
    return self._post("watcheddir", ApiWatchedDir, data=req, api_version=14)
24273
def run_process(path: Union[Path, str], target: Callable, *,
                args: Tuple=(),
                kwargs: Dict[str, Any]=None,
                callback: Callable[[Set[Tuple[Change, str]]], None]=None,
                watcher_cls: Type[AllWatcher]=PythonWatcher,
                debounce=400,
                min_sleep=100):
    

    process = _start_process(target=target, args=args, kwargs=kwargs)
    reloads = 0

    for changes in watch(path, watcher_cls=watcher_cls, debounce=debounce, min_sleep=min_sleep):
        callback and callback(changes)
        _stop_process(process)
        process = _start_process(target=target, args=args, kwargs=kwargs)
        reloads += 1
    return reloads
288829
def watch(self, path, action, *args, **kwargs):
        
        if action is None:
            action = _set_changed
        event_handler = _WatchdogHandler(self, action)
        self._observer.schedule(event_handler, path=path, recursive=True)
691258
public static WatchMonitor createAll(Path path, Watcher watcher){
		final WatchMonitor watchMonitor = create(path, EVENTS_ALL);
		watchMonitor.setWatcher(watcher);
		return watchMonitor;
	}
153892
def _run_path(self, path_num):
        
        # pre processing
        self.producer.initialize_path(path_num)
        self.consumer.initialize_path(path_num)

        # processing
        for new_date in self.grid:
            state = self.producer.evolve(new_date)
            self.consumer.consume(state)

        # post processing
        self.consumer.finalize_path(path_num)
1200468
def post(self, *args):
        
        filepath = self.get_body_argument('filepath')
        if not self.fs.exists(filepath):
            raise tornado.web.HTTPError(404)

        Filewatcher.add_directory_to_watch(filepath)
        self.write({'msg':'Watcher added for {}'.format(filepath)})
1159754
def setup_file_watcher(path, use_polling=False):
    
    if use_polling:
        observer_class = watchdog.observers.polling.PollingObserver
    else:
        observer_class = EVENTED_OBSERVER

    file_event_handler = _SourceChangesHandler(patterns=["*.py"])
    file_watcher = observer_class()
    file_watcher.schedule(file_event_handler, path, recursive=True)
    file_watcher.start()
    return file_watcher