def get_param(self, name): value = self.cfg.get(name) if not value: raise pulsar.ImproperlyConfigured( 'Please specify the "%s" parameter in your %s file' % (name, self.cfg.config)) return value
async def monitor_start(self, monitor): '''Create the socket listening to the ``bind`` address. If the platform does not support multiprocessing sockets set the number of workers to 0. ''' cfg = self.cfg loop = monitor._loop if (not pulsar.platform.has_multiProcessSocket or cfg.concurrency == 'thread'): cfg.set('workers', 0) if not cfg.address: raise pulsar.ImproperlyConfigured('Could not open a socket. ' 'No address to bind to') address = parse_address(self.cfg.address) # First create the sockets transport, _ = await loop.create_datagram_endpoint( asyncio.DatagramProtocol, address) sock = transport.get_extra_info('socket') self.monitor_sockets(monitor, [sock]) # TODO: if we don't do this the socket get closed for some reason try: del transport._sock except AttributeError: pass
def monitor_start(self, monitor): '''Create the socket listening to the ``bind`` address. If the platform does not support multiprocessing sockets set the number of workers to 0. ''' cfg = self.cfg loop = monitor.event_loop if (not pulsar.platform.has_multiProcessSocket or cfg.concurrency == 'thread'): cfg.set('workers', 0) if not cfg.address: raise pulsar.ImproperlyConfigured('Could not open a socket. ' 'No address to bind to') ssl = None if cfg.cert_file or cfg.key_file: if cfg.cert_file and not os.path.exists(cfg.cert_file): raise ValueError('cert_file "%s" does not exist' % cfg.cert_file) if cfg.key_file and not os.path.exists(cfg.key_file): raise ValueError('key_file "%s" does not exist' % cfg.key_file) ssl = SSLContext(keyfile=cfg.key_file, certfile=cfg.cert_file) address = parse_address(self.cfg.address) # First create the sockets sockets = yield loop.start_serving(lambda: None, *address) addresses = [] for sock in sockets: assert loop.remove_reader( sock.fileno()), ("Could not remove reader") addresses.append(sock.getsockname()) monitor.params.sockets = [WrapSocket(s) for s in sockets] monitor.params.ssl = ssl self.addresses = addresses self.address = addresses[0]
def _iter_app(self, app_name_callables): main = app_name_callables.pop('', None) if not main: raise pulsar.ImproperlyConfigured( 'No main application in MultiApp') yield main for app in app_name_callables.values(): yield app
async def monitor_start(self, monitor): '''Create the socket listening to the ``bind`` address. If the platform does not support multiprocessing sockets set the number of workers to 0. ''' cfg = self.cfg if (not pulsar.platform.has_multiProcessSocket or cfg.concurrency == 'thread'): cfg.set('workers', 0) if not cfg.address: raise pulsar.ImproperlyConfigured('Could not open a socket. ' 'No address to bind to') address = parse_address(self.cfg.address) server = await self.create_server(monitor, address) monitor.servers[self.name] = server self.cfg.addresses = server.addresses
def get_backend(self, store=None): if self.backend is None: if store is None: store = create_store(self.cfg.task_backend) else: self.cfg.set('task_backend', store.dns) task_backend = task_backends.get(store.name) if not task_backend: raise pulsar.ImproperlyConfigured( 'Task backend for %s not available' % store.name) self.backend = task_backend( store, logger=self.logger, name=self.name, task_paths=self.cfg.task_paths, schedule_periodic=self.cfg.schedule_periodic, max_tasks=self.cfg.max_requests, backlog=self.cfg.concurrent_tasks) self.logger.debug('created %s', self.backend) return self.backend
def monitor_start(self, monitor): '''Create the socket listening to the ``bind`` address. If the platform does not support multiprocessing sockets set the number of workers to 0. ''' cfg = self.cfg loop = monitor._loop if (not pulsar.platform.has_multiProcessSocket or cfg.concurrency == 'thread'): cfg.set('workers', 0) if not cfg.address: raise pulsar.ImproperlyConfigured('Could not open a socket. ' 'No address to bind to') address = parse_address(self.cfg.address) # First create the sockets t, _ = yield from loop.create_datagram_endpoint( asyncio.DatagramProtocol, address) sock = t.get_extra_info('socket') assert loop.remove_reader(sock.fileno()) cfg.addresses = [sock.getsockname()] monitor.sockets = [WrapTransport(t)]