adds trailing stop to monitor list
353095
def registerTrailingStop(self, tickerId, orderId=0, quantity=1,
            lastPrice=0, trailPercent=100., trailAmount=0., parentId=0, **kwargs):
        

        ticksize = self.contractDetails(tickerId)["m_minTick"]

        trailingStop = self.trailingStops[tickerId] = {
            "orderId": orderId,
            "parentId": parentId,
            "lastPrice": lastPrice,
            "trailAmount": trailAmount,
            "trailPercent": trailPercent,
            "quantity": quantity,
            "ticksize": ticksize
        }

        return trailingStop
18924
function monitor(interval, timeoutCb, pingTimeout) {
  pingTimeout = pingTimeout || interval;
  let currentTimeout;
  let currentInterval;
  let closed = false;

  const onTimeoutExpired = () => {
    if (closed) return;
    closed = true;

    clearTimeout(currentTimeout);
    clearInterval(currentInterval);
    timeoutCb();
  };


  const ping = () => {
    this.ping(undefined, undefined, true);

    if (currentTimeout) return;
    currentTimeout = setTimeout(onTimeoutExpired, pingTimeout);
  };

  this.on('pong', () => {
    clearTimeout(currentTimeout);
    currentTimeout = undefined;
  });

  this.on('close', () => onTimeoutExpired());
  this.on('error', () => onTimeoutExpired());
  currentInterval = setInterval(() => ping(), interval);
}
716301
def stop(self):
        
        self.elapse = time.clock() - self.st
        self.records.append(self.elapse)
790133
function notifyWatchersOnPaths(paths) {
    var expandedPaths = _expandNestedPaths(paths);

    watchers.map(function _notifyWatcher(watcher) {
      var hasPath = intersect(expandedPaths, watcher.paths).length > 0;

      if (hasPath) {
        var watchedKeyValues = {};
        try {
          watchedKeyValues = getAll(paths);
        } catch (e) {}

        if (watcher.options.async !== false) {
          setTimeout(function () {
            watcher.callback(watchedKeyValues);
          }, watcher.options.async || 0);
        } else {
          watcher.callback(watchedKeyValues);
        }
      }
    });

    if (paths !== '*') {
      notifyGlobalWatchers();
    }
  }
50520
public void addStackedSimons() {
		Split splitA = SimonManager.getStopwatch("Y.A").start();
		Split splitB = SimonManager.getStopwatch("Y.B").start();
		addStopwatchSplits(SimonManager.getStopwatch("Y.C"), 6);
		splitB.stop();
		Split splitD = SimonManager.getStopwatch("Y.D").start();
		randomWait(100, 250);
		randomWait(100, 250);
		splitD.stop();
		splitA.stop();
	}
1038115
def remove_trailing_stars(self, new_path=None, in_place=True, check=False):
        """"""
        # Optional check #
        if check and int(sh.grep('-c', '\*', self.path, _ok_code=[0,1])) == 0: return self
        # Faster with bash utilities #
        if in_place is True:
            sh.sed('-i', 's/\*$//g', self.path)
            return self
        # Standard way #
        if new_path is None: new_fasta = self.__class__(new_temp_path())
        else:                new_fasta = self.__class__(new_path)
        new_fasta.create()
        for seq in self: new_fasta.add_str(str(seq.seq).rstrip('*'), seq.id)
        new_fasta.close()
        return new_fasta
1118048
def stopdocs():
    ""
    for i in range(4):
        pid = watchdog_pid()
        if pid:
            if not i:
                sh('ps {}'.format(pid))
            sh('kill {}'.format(pid))
            time.sleep(.5)
        else:
            break
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;
    }
1017684
protected void onStopwatchSplit(Stopwatch stopwatch, Split split) {
		Buckets buckets = getOrCreateBuckets(stopwatch);
		if (buckets != null) {
			buckets.addValue(split.runningFor());
			buckets.log(split);
		}
	}
290796
function setCallbackAsWatcherOf(callback, watchersSet) {
    if (!callback[WATCHER_IDENTIFIER]) {
        defineProperty(callback, WATCHER_IDENTIFIER, { watching: new Set() });

        defineProperty(callback, "stopWatchingAll", function(){
            callback[WATCHER_IDENTIFIER].watching.forEach(watcherList =>
                watcherList.delete(callback)
            );
            callback[WATCHER_IDENTIFIER].watching.clear();
        });
    }

    callback[WATCHER_IDENTIFIER].watching.add(watchersSet);
}
292164
def extend_off_air( programs, program, stop )
      prev       = programs.pop + program
      program    = prev.program
      occurrence = prev.occurrence
      remainder  = time_left( occurrence.start_time, occurrence.end_time, stop )

      [ program, occurrence, remainder ]
    end
62610
def _start_monitoring(self):
        
        
        # Grab all the timestamp info
        before = self._file_timestamp_info(self.path)

        while True:
            gevent.sleep(1)
            after = self._file_timestamp_info(self.path)

            added = [fname for fname in after.keys() if fname not in before.keys()]
            removed = [fname for fname in before.keys() if fname not in after.keys()]
            modified = []

            for fname in before.keys():
                if fname not in removed:
                    if os.path.getmtime(fname) != before.get(fname):
                        modified.append(fname)

            if added: 
                self.on_create(added)
            if removed: 
                self.on_delete(removed)
            if modified: 
                self.on_modify(modified)
    
            before = after
1185539
public void monitorEnter(Local<?> monitor) {
        addInstruction(new ThrowingInsn(Rops.MONITOR_ENTER, sourcePosition,
                RegisterSpecList.make(monitor.spec()), catches));
    }
360223
def stop_plugins(watcher_plugin, health_plugin):
    
    logging.debug("Stopping health-check monitor...")
    health_plugin.stop()

    logging.debug("Stopping config change observer...")
    watcher_plugin.stop()
161314
private void sawMonitorEnter(int pc) {
        monitorSyncPCs.add(Integer.valueOf(pc));

        ScopeBlock sb = new ScopeBlock(pc, Integer.MAX_VALUE);
        sb.setSync();
        rootScopeBlock.addChild(sb);
    }
744396
private void sawMonitorExit(int pc) {
        if (!monitorSyncPCs.isEmpty()) {
            ScopeBlock sb = findSynchronizedScopeBlock(rootScopeBlock, monitorSyncPCs.get(0).intValue());
            if (sb != null) {
                sb.setFinish(pc);
            }
            monitorSyncPCs.remove(monitorSyncPCs.size() - 1);
        }
    }
924704
public CompositeProgressMonitor addProgressMonitor(ProgressMonitor monitor) {
    this.monitors.add(monitor);
    monitor.addCancelListener(cancelListeners);
    return this;
  }