lib/task/worker.py
def run(self):
        '''
        Starts the worker thread, running an infinite loop waiting for jobs.

        This should be run on an alternate thread, as it will block.
        '''
        task_queue = self.pool.queue    # type: queue.Queue

        logger.debug('task worker starting: %r', self)
        while True:
            # explicitly specify `block`, in case the queue has custom settings
            task = task_queue.get(block=True)   # type: Task

            if task is not None:
                # NOTE : Tasks should catch their own exceptions.
                try:
                    task.run()
                except Exception as e:
                    logger.error(
                        'exception during task execution: %r',
                        e, exc_info=True,
                    )

                # explicitly clear reference to task
                del task
                continue

            # task is none, so check if a shutdown is requested
            if not self.pool.running:
                logger.debug('task pool has stopped running, exit loop')

                # pass on the signal to any other worker threads
                try:
                    task_queue.put(None, block=True, timeout=1)
                except queue.Full:
                    logger.warning(
                        'task queue is full, '
                        'cannot signal other workers to exit'
                    )

                break

            logger.warning('unhandled task on worker thread: %r', task)

        logger.debug('task worker exiting:  %r', self)

        Starts the worker thread, running an infinite loop waiting for jobs.

        This should be run on an alternate thread, as it will block.
        
Starts the worker thread, running an infinite loop waiting for jobs.
This should be run on an alternate thread, as it will block.
Starts the worker thread running an infinite loop waiting for jobs . This should be run on an alternate thread as it will block .
def run(self):
        task_queue = self.pool.queue    
        logger.debug('task worker starting: %r', self)
        while True:
            task = task_queue.get(block=True)   
            if task is not None:
                try:
                    task.run()
                except Exception as e:
                    logger.error(
                        'exception during task execution: %r',
                        e, exc_info=True,
                    )
                del task
                continue
            if not self.pool.running:
                logger.debug('task pool has stopped running, exit loop')
                try:
                    task_queue.put(None, block=True, timeout=1)
                except queue.Full:
                    logger.warning(
                        'task queue is full, '
                        'cannot signal other workers to exit'
                    )
                break
            logger.warning('unhandled task on worker thread: %r', task)
        logger.debug('task worker exiting:  %r', self)
def run ( self ) : task_queue = self . pool . queue logger . debug ( 'task worker starting: %r' , self ) while True : task = task_queue . get ( block = True ) if task is not None : try : task . run ( ) except Exception as e : logger . error ( 'exception during task execution: %r' , e , exc_info = True , ) del task continue if not self . pool . running : logger . debug ( 'task pool has stopped running, exit loop' ) try : task_queue . put ( None , block = True , timeout = 1 ) except queue . Full : logger . warning ( 'task queue is full, ' 'cannot signal other workers to exit' ) break logger . warning ( 'unhandled task on worker thread: %r' , task ) logger . debug ( 'task worker exiting:  %r' , self )
Starts the worker thread, running an infinite loop waiting for jobs.
Starts the worker thread running an infinite loop waiting for jobs .
'''
        Starts the worker thread, running an infinite loop waiting for jobs.

        This should be run on an alternate thread, as it will block.
        ''' # type: queue.Queue # explicitly specify `block`, in case the queue has custom settings # type: Task # NOTE : Tasks should catch their own exceptions. # explicitly clear reference to task # task is none, so check if a shutdown is requested # pass on the signal to any other worker threads
self