def init_schedulers(): schedulers = [ HeartbeatScheduler, MessageFetchScheduler, MessageCacheScheduler, TaskSyncScheduler, StatusScheduler ] logger.info('Initializing schedulers') for scheduler_cls in schedulers: scheduler = scheduler_cls() logger.info('Add %s to ioloop', scheduler_cls.__name__) get_io_loop().spawn_callback(scheduler.eventloop)
def __init__(self): self._stream_name = config['kinesis_stream'] self._pending_records = [] if not self._stream_name: raise Boto3Error('kinesis_stream should not be empty') self._kinesis_kwargs = dict( service_name='kinesis', aws_access_key_id=config['aws_access_key_id'], aws_secret_access_key=config['aws_secret_access_key'], region_name=config['aws_region']) get_io_loop().spawn_callback(self.run)
def init_first_report(): report = get_first_report() message = Message.create(MessageType.INFO, body=report) transfer = get_current_transfer() result = get_io_loop().run_sync(lambda: transfer.send(message)) if not result: logger.error('Upload report failed') sys.exit(-1)
def __init__(self, task_id, stream): super(PythonTask, self).__init__(task_id) if isinstance(stream, unicode): self.content = stream.encode('utf-8') elif isinstance(stream, str): self.content = stream else: self.content = stream.read() self._io_loop = get_io_loop()
def __init__(self): self._cursor = self.get_cursor() url = urlparse.urljoin(config['upstream'], 'dispatcher/message') self._base_url = utils.update_query_params(url, { 'tenant': config['tenant'], 'id': config['id'] }) self._retry_times = 0 self._retry_interval = config.get('message_fetch_retry_interval', 5) self._http_client = httpclient.AsyncHTTPClient(io_loop=get_io_loop())
import os
def init_io_loop(): logger.info('Startup io loop') get_io_loop().start()
def __init__(self): url = urlparse.urljoin(config['upstream'], 'dispatcher/message') self._url = utils.update_query_params(url, {'tenant': config['tenant']}) self._http_client = AsyncHTTPClient(io_loop=get_io_loop())
def get_new_ioloop(self): return get_io_loop()