Watch for Processing Block events.
553473
def _monitor_events(self):
        """"""
        LOG.info("Starting to monitor PB events")
        check_counter = 0
        while True:
            if check_counter == 50:
                check_counter = 0
                LOG.debug('Checking for PB events...')

            published_events = self._pb_events.get_published_events()
            for event in published_events:
                if event.type == 'status_changed':
                    LOG.info('PB status changed event: %s',
                             event.data['status'])

                    if event.data['status'] == 'created':
                        LOG.info('Acknowledged PB created event (%s) for %s, '
                                 '[timestamp: %s]', event.id,
                                 event.object_id, event.timestamp)
                        pb = ProcessingBlock(event.object_id)
                        self._queue.put(event.object_id, pb.priority, pb.type)

                    if event.data['status'] == 'completed':
                        LOG.info('Acknowledged PB completed event (%s) for %s,'
                                 ' [timestamp: %s]', event.id,
                                 event.object_id, event.timestamp)
                        self._num_pbcs -= 1
                        if self._num_pbcs < 0:
                            self._num_pbcs = 0

            time.sleep(0.1)
            check_counter += 1
1223091
private void checkAndProcessFileInfo(WatchKey key, List<FileInfo> fileInfos) {
        for (WatchEvent<?> event : key.pollEvents()) {
            WatchEvent.Kind kind = event.kind();

            for (FileInfo fileInfo : fileInfos) {
                if (kind == OVERFLOW) {
                    try {
                        throw new IncompleteFileEventException();
                    } catch (IncompleteFileEventException e) {
                        log.warn(e);
                    }
                } else if ((kind == ENTRY_CREATE || kind == ENTRY_MODIFY || kind == ENTRY_DELETE)
                        && isFileType(event, fileInfo.getFileType())) {
                    try {
                        if (fileInfo.getReloadableFile() != null) {
                            fileInfo.getReloadableFile().reloadFile(kind.toString());
                            debug("Reloaded file: " + event.context().toString());
                            getMain().getFilePublisher().notifyFileSubscribers(fileInfo.getReloadableFile());
                        }
                    } catch (Exception e) {
                        log.warn(e);
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        log.warn(e);
                    }
                }
            }
        }
    }
61986
def watch_activations(self, flag):
        """"""
        lib.EnvSetDefruleWatchActivations(self._env, int(flag), self._rule)
1234942
@Override
	public void run() {

		while (!stopProcessing.get()) {

			try {
				JawrWatchEvent evt = watchEvents.take();
				AtomicBoolean processingBundle = bundlesHandler.isProcessingBundle();
				synchronized (processingBundle) {

					// Wait until processing ends
					while (processingBundle.get() && !stopProcessing.get()) {
						try {
							processingBundle.wait();
						} catch (InterruptedException e) {
							LOGGER.debug("Thread interrupted");
						}
					}
				}
				if (evt != null && !stopProcessing.get()) {
					process(evt);
				}
			} catch (InterruptedException e) {
				LOGGER.debug("Thread interrupted");
			}
		}
		
		this.bundlesHandler = null;
		this.watcher = null;
	}
79825
def watch(self, limit=None, timeout=None):
        """"""
        start_time = time.time()
        count = 0
        while not timeout or time.time() - start_time < timeout:
            new = self.read()
            if new != self.temp:
                count += 1
                self.callback(new)
                if count == limit:
                    break
            self.temp = new
            time.sleep(self.interval)
492348
protected void process(BlockPos pos)
	{
		for (EnumFacing dir : searchDirs)
		{
			BlockPos newPos = pos.offset(dir);
			if (!processed.contains(newPos) && shouldProcessed(newPos))
				toProcess.add(newPos);
		}
		processed.add(pos);
		if (processed.size() >= countLimit)
			toProcess.clear();
	}
1351118
public void observeProcessValidations(@Observes @Before @ProcessValidations PhaseEvent event) {
        log.debug("After Process Validations event");
        performObservation(event, PhaseIdType.PROCESS_VALIDATIONS);
    }
615828
function () {
    const oThis = this
    ;

    oThis.snmData.lastProcessedBlock = oThis.toBlock;

    fs.writeFileSync(
      oThis.filePath,
      JSON.stringify(oThis.snmData),
      function (err) {
        if (err)
          logger.error(err);
      }
    );

    if (oThis.interruptSignalObtained) {
      logger.info('Exiting Process....');
      process.exit(1);
    }
  }
350164
private CallbackResult<V> processListeners(Set<BlockPos> list, Chunk chunk, Object... params)
	{
		CallbackResult<V> result = CallbackResult.noResult();
		for (BlockPos listener : list)
		{
			CallbackResult<V> tmp = super.processCallbacks(chunk, listener, params);
			result = reduce.apply(result, tmp);
			if (result.isForcedCancelled())
				return result;
		}
		return result;
	}
859826
def check_bcr_catchup(self):
        """"""
        logger.debug(f"Checking if BlockRequests has caught up {len(BC.Default().BlockRequests)}")

        # test, perhaps there's some race condition between slow startup and throttle sync, otherwise blocks will never go down
        for peer in self.Peers:  # type: NeoNode
            peer.stop_block_loop(cancel=False)
            peer.stop_peerinfo_loop(cancel=False)
            peer.stop_header_loop(cancel=False)

        if len(BC.Default().BlockRequests) > 0:
            for peer in self.Peers:
                peer.keep_alive()
                peer.health_check(HEARTBEAT_BLOCKS)
                peer_bcr_len = len(peer.myblockrequests)
                # if a peer has cleared its queue then reset heartbeat status to avoid timing out when resuming from "check_bcr" if there's 1 or more really slow peer(s)
                if peer_bcr_len == 0:
                    peer.start_outstanding_data_request[HEARTBEAT_BLOCKS] = 0

                print(f"{peer.prefix} request count: {peer_bcr_len}")
                if peer_bcr_len == 1:
                    next_hash = BC.Default().GetHeaderHash(self.CurrentBlockheight + 1)
                    print(f"{peer.prefix} {peer.myblockrequests} {next_hash}")
        else:
            # we're done catching up. Stop own loop and restart peers
            self.stop_check_bcr_loop()
            self.check_bcr_loop = None
            logger.debug("BlockRequests have caught up...resuming sync")
            for peer in self.Peers:
                peer.ProtocolReady()  # this starts all loops again
                # give a little bit of time between startup of peers
                time.sleep(2)
80302
def on(event)
      EVENT_TYPES.include?(event) or (self.class.logger.error "Invalid event #{event}" and return)
      block_given? and @blocks[event] << Proc.new
    end
289186
def watch(self, flag):
        """"""
        lib.EnvSetDeffunctionWatch(self._env, int(flag), self._fnc)
189659
function processMaybeBlock(node, baseToken) {
            const firstToken = getFirstAndLastTokens(node).firstToken
            setOffsetToToken(
                firstToken,
                isLeftBrace(firstToken) ? 0 : 1,
                baseToken
            )
        }
474976
async def trigger(self, event, kwargs):
        
        await self._queue.put((event, kwargs))
        self._resume_processing.set()
1068832
public static void processPostSetBlock(Chunk chunk, BlockPos pos, IBlockState oldState, IBlockState newState)
	{
		postSetBlockRegistry.processCallbacks(chunk, pos, oldState, newState);
	}
278518
def process_events(self):
        """"""
        for event, args in iter_except(self.event_queue.popleft, IndexError):
            for callback in self.event_callbacks[event]:
                callback(*args)
1074975
def watch(self):
        """"""
        return bool(lib.EnvGetDefmessageHandlerWatch(
            self._env, self._cls, self._idx))