How to use the pebble.pool.process.BrokenProcessPool function in Pebble

To help you get started, we’ve selected a few Pebble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github noxdafox / pebble / pebble / pool / process.py View on Github external
def new_worker(self):
        try:
            worker = launch_process(
                worker_process, self.worker_parameters, self.workers_channel)
            self.workers[worker.pid] = worker
        except (OSError, EnvironmentError) as error:
            raise BrokenProcessPool(error)
github noxdafox / pebble / pebble / pool / process.py View on Github external
def stop_worker(self, worker_id, force=False):
        try:
            if force:
                stop_process(self.workers.pop(worker_id))
            else:
                with self.workers_channel.lock:
                    stop_process(self.workers.pop(worker_id))
        except ChannelError as error:
            raise BrokenProcessPool(error)
        except KeyError:
            return  # worker already expired
github noxdafox / pebble / pebble / pool / process.py View on Github external
context = pool_manager.context
    task_queue = context.task_queue

    try:
        while context.alive:
            task = task_queue.get()

            if task is not None:
                if task.future.cancelled():
                    task.set_running_or_notify_cancel()
                    task_queue.task_done()
                else:
                    pool_manager.schedule(task)
            else:
                task_queue.task_done()
    except BrokenProcessPool:
        context.state = ERROR
github noxdafox / pebble / pebble / pool / process.py View on Github external
def stop_worker(self, worker_id, force=False):
        try:
            if force:
                stop_process(self.workers.pop(worker_id))
            else:
                with self.workers_channel.lock:
                    stop_process(self.workers.pop(worker_id))
        except ChannelError as error:
            raise BrokenProcessPool(error)
        except KeyError:
            return  # worker already expired
github noxdafox / pebble / pebble / pool / process.py View on Github external
def new_worker(self):
        try:
            worker = launch_process(
                None, worker_process, True, self.worker_parameters, self.workers_channel)
            self.workers[worker.pid] = worker
        except (OSError, EnvironmentError) as error:
            raise BrokenProcessPool(error)
github noxdafox / pebble / pebble / pool / process.py View on Github external
def receive(self, timeout):
        try:
            if self.pool_channel.poll(timeout):
                return self.pool_channel.recv()
            else:
                return NoMessage()
        except (OSError, EnvironmentError, TypeError) as error:
            raise BrokenProcessPool(error)
github noxdafox / pebble / pebble / pool / process.py View on Github external
context = pool_manager.context
    task_queue = context.task_queue

    try:
        while context.alive:
            task = task_queue.get()

            if task is not None:
                if task.future.cancelled():
                    task.future.set_running_or_notify_cancel()
                    task_queue.task_done()
                else:
                    pool_manager.schedule(task)
            else:
                task_queue.task_done()
    except BrokenProcessPool:
        context.state = ERROR
github noxdafox / pebble / pebble / pool / process.py View on Github external
def find_expired_task(self, worker_id):
        tasks = tuple(self.task_manager.tasks.values())
        running_tasks = tuple(t for t in tasks if t.worker_id != 0)

        if running_tasks:
            return task_worker_lookup(running_tasks, worker_id)
        else:
            raise BrokenProcessPool("All workers expired")
github noxdafox / pebble / pebble / pool / process.py View on Github external
def dispatch(self, task):
        try:
            self.pool_channel.send(WorkerTask(task.id, task.payload))
        except (pickle.PicklingError, TypeError) as error:
            raise error
        except (OSError, EnvironmentError, TypeError) as error:
            raise BrokenProcessPool(error)