this main routine sets up the signal handlers, the source and
        destination crashstorage systems at the  theaded task manager.  That
        starts a flock of threads that are ready to shepherd crashes from
        the source to the destination.
321909
def main(self):
        """"""

        self._setup_task_manager()
        self._setup_source_and_destination()
        self.task_manager.blocking_start(waiting_func=self.waiting_func)
        self.close()
        self.config.logger.info('done.')
1039976
function initTerminateHandlers() {
  var readLine;

  if (process.platform === "win32"){
    readLine = require("readline");

    readLine.createInterface ({
      input: process.stdin,
      output: process.stdout
    }).on("SIGINT", function () {
      process.emit("SIGINT");
    });
  }

  // handle INTERRUPT (CTRL+C) and TERM/KILL signals
  process.on('exit', function () {
    if (server) {
      console.log(chalk.blue('*'), 'Shutting down server');
      server.stop();
    }
    console.log();  // extra blank line
  });
  process.on('SIGINT', function () {
    console.log(chalk.blue.bold('!'), chalk.yellow.bold('SIGINT'), 'detected');
    process.exit();
  });
  process.on('SIGTERM', function () {
    console.log(chalk.blue.bold('!'), chalk.yellow.bold('SIGTERM'), 'detected');
    process.exit(0);
  });
}
1158114
def setup_handler(self, io_loop):
		
		WNativeSocketHandler.setup_handler(self, io_loop)
		if self.server_mode() is False:
			self.io_handler().transport_socket().sendto(
				self.io_handler().messenger().request(self.config()),
				self.transport().target_socket(self.config()).pair()
			)
1000019
protected void initIncidentHandlers() {
    if (incidentHandlers == null) {
      incidentHandlers = new HashMap<String, IncidentHandler>();

      DefaultIncidentHandler failedJobIncidentHandler = new DefaultIncidentHandler(Incident.FAILED_JOB_HANDLER_TYPE);
      incidentHandlers.put(failedJobIncidentHandler.getIncidentHandlerType(), failedJobIncidentHandler);

      DefaultIncidentHandler failedExternalTaskIncidentHandler = new DefaultIncidentHandler(Incident.EXTERNAL_TASK_HANDLER_TYPE);
      incidentHandlers.put(failedExternalTaskIncidentHandler.getIncidentHandlerType(), failedExternalTaskIncidentHandler);
    }
    if (customIncidentHandlers != null) {
      for (IncidentHandler incidentHandler : customIncidentHandlers) {
        incidentHandlers.put(incidentHandler.getIncidentHandlerType(), incidentHandler);
      }
    }
  }
867053
def add_startup_handler(self, handler):
        """"""
        if not self.startup_handlers:
            self._startup_handlers = []

        self.startup_handlers.append(handler)
532589
function setupHandlers() {

    function terminate(err) {
        util.log('Uncaught Error: ' + err.message);
        console.log(err.stack);
        if (proc.shutdownHook) {
            proc.shutdownHook(err, gracefulShutdown);
        }
    }

    process.on('uncaughtException', terminate);

    process.addListener('SIGINT', gracefulShutdown);

    process.addListener('SIGHUP', function () {
        util.log('RECIEVED SIGHUP signal, reloading log files...');
        reload(argv);
    });

}
1337654
def add_signal_handlers(self):
        """"""
        try:
            self.loop.add_signal_handler(signal.SIGHUP, self.SIGHUP)
        except (RuntimeError, AttributeError):  # pragma: no cover
            # windows
            pass
        try:
            self.loop.add_signal_handler(signal.SIGINT, self.SIGINT)
        except (RuntimeError, NotImplementedError):  # pragma: no cover
            # annaconda
            pass
1342336
private void init(){

		errorProducerEnabled = MoskitoConfigurationHolder.getConfiguration().getBuiltinProducersConfig().isErrorProducer();

		statsMap = new ConcurrentHashMap<>();
        statsList = new CopyOnWriteArrayList<>();

		cumulatedStats = new ErrorStats("cumulated");
		statsList.add(cumulatedStats);

		catchers = new ConcurrentHashMap<>();

		//it is complicated to actually remove the error producer from the system if disabled, but the flag renders it invisible and
		//disables most methos.
		if (!errorProducerEnabled)
			return;

		ProducerRegistryFactory.getProducerRegistryInstance().registerProducer(this);


		//add charts for cumulated errors.
		AfterStartTasks.submitTask(new Runnable() {
			@Override
			public void run() {
				AccumulatorRepository.getInstance().createAccumulator(createAccumulatorDefinition("Errors.Cumulated.Total", "total", "cumulated"));
			}
		});
		AfterStartTasks.submitTask(new Runnable() {
			@Override
			public void run() {
				AccumulatorRepository.getInstance().createAccumulator(createAccumulatorDefinition("Errors.Cumulated.Initial", "initial", "cumulated"));
			}
		});

		errorHandlingConfig = null;
	}
712418
def _start_payloads(self):
        """"""
        with self._lock:
            payloads = self._payloads.copy()
            self._payloads.clear()
        for subroutine in payloads:
            thread = CapturingThread(target=subroutine)
            thread.start()
            self._threads.add(thread)
            self._logger.debug('booted thread %s', thread)
        time.sleep(0)
1022441
def _setup_task_manager(self):
        """"""
        self.config.logger.info('installing signal handers')
        # set up the signal handler for dealing with SIGTERM. the target should
        # be this app instance so the signal handler can reach in and set the
        # quit flag to be True.  See the 'respond_to_SIGTERM' method for the
        # more information
        respond_to_SIGTERM_with_logging = partial(
            respond_to_SIGTERM,
            target=self
        )
        signal.signal(signal.SIGTERM, respond_to_SIGTERM_with_logging)
        self.task_manager = \
            self.config.producer_consumer.producer_consumer_class(
                self.config.producer_consumer,
                job_source_iterator=self.source_iterator,
                task_func=self.transform
            )
        self.config.executor_identity = self.task_manager.executor_identity
42943
@Override
    protected void onStart() {
        logger.info("Starting DoTaskApp... App Partition [{}]", this.getPartitionId());
        // <<<<<<< HEAD Task doesn't have start in latest storm-impl
        // TODO change the way the app starts
        // if (this.getPartitionId() == 0)
        S4Topology s4topology = (S4Topology) getTask().getTopology();
        S4EntranceProcessingItem epi = (S4EntranceProcessingItem) s4topology.getEntranceProcessingItem();
        while (epi.injectNextEvent())
            // inject events from the EntrancePI
            ;
    }
278971
final void signalWork() {
        for (;;) {
            long c; int sp, i; WorkQueue v; WorkQueue[] ws;
            if ((c = ctl) >= 0L)                      // enough workers
                break;
            else if ((sp = (int)c) == 0) {            // no idle workers
                if ((c & ADD_WORKER) != 0L)           // too few workers
                    tryAddWorker(c);
                break;
            }
            else if ((ws = workQueues) == null)
                break;                                // unstarted/terminated
            else if (ws.length <= (i = sp & SMASK))
                break;                                // terminated
            else if ((v = ws[i]) == null)
                break;                                // terminating
            else {
                int ns = sp & ~UNSIGNALLED;
                int vs = v.scanState;
                long nc = (v.stackPred & SP_MASK) | (UC_MASK & (c + AC_UNIT));
                if (sp == vs && U.compareAndSwapLong(this, CTL, c, nc)) {
                    v.scanState = ns;
                    LockSupport.unpark(v.parker);
                    break;
                }
            }
        }
    }
880430
def setup_handler(self, io_loop):
		

		if self.server_mode() is True:
			s = self.transport().server_socket(self.config())
		else:
			s = self.transport().client_socket(self.config())

		io_handler = self.io_handler()
		if isinstance(io_handler, WNativeSocketDirectIOHandler) is True:
			io_handler.transport_socket(s)
		io_loop.add_handler(s.fileno(), io_handler.handler_fn, io_loop.READ)
896093
def _setup_source_and_destination(self):
        
        super(FetchTransformSaveWithSeparateNewCrashSourceApp, self) \
            ._setup_source_and_destination()
        if self.config.new_crash_source.new_crash_source_class:
            self.new_crash_source = \
                self.config.new_crash_source.new_crash_source_class(
                    self.config.new_crash_source,
                    name=self.app_instance_name,
                    quit_check_callback=self.quit_check
                )
        else:
            # the configuration failed to provide a "new_crash_source", fall
            # back to tying the "new_crash_source" to the "source".
            self.new_crash_source = self.source
1065882
@Override
    public final void run() {
        for (; ; ) {
            final BaasHandler<?> curr = suspendableHandler.get();
            // at this stage we are in the callback thread of execution
            // we get the current handler and choose the state to reach
            if (curr == Signal.COMMITTED) {
                //the callback has already run
                // really we don't have to make any work
                return;
            }

            final BaasHandler<?> target;
            if (curr == Signal.SUSPENDED || curr == Signal.DELIVERED) {
                //if the current state is SUSPENDED the target state
                //to reach is DELIVERED
                //handlers in DELIVERED state won't change and remain the same
                //so for both the cases the target state would be
                // DELIVERED and there would be no more work to do
                target = Signal.DELIVERED;
            } else {
                // we have a real handler to execute
                // and we need to commit the execution
                target = Signal.COMMITTED;
            }

            if (suspendableHandler.compareAndSet(curr, target)) {
                //at this point the transition is completed
                //if the target we reached is COMMITTED than we have
                //to execute the callback and cleanup the dispatcher
                if (target == Signal.COMMITTED) {
                    if (curr != null) {
                        ((BaasHandler<R>) curr).handle(result);
                    }
                    finish();
                }
                return;
            }
        }
    }
626851
public void initialize() {
		mIsForceStop = false;
		mTagStack.clear();
		mTagValueCache.clear();
		mTagAttrCache.clear();
		mCurrentTagKey = null;
	}
1243313
private void initialize(Handler callbackHandler, int threadPoolSize) {
		mDownloadDispatchers = new DownloadDispatcher[threadPoolSize];
		mDelivery = new CallBackDelivery(callbackHandler);
	}