# Path: lacli/log.py
# def getLogger(logger='lacli'):
#     return lacore.log.getLogger(logger)
# 
# Path: lacli/exceptions.py
# class PauseEvent(BaseAppException):
#     msg = "Paused"


from lacli.log import getLogger
from lacli.exceptions import PauseEvent
from multiprocessing import Queue, active_children
from Queue import Empty


class ControlHandler(object):

    def __init__(self):
        self.q = None

    def __enter__(self):
        self.q = Queue()
        controlByQueue(self.q)
        return self.q

    def __exit__(self, type, value, traceback):
        getLogger().debug("control handler exiting.")
        if type == KeyboardInterrupt:
            getLogger().debug("upload pausing.")
            self.pause()
            type = None
        stopControlByQueue()
        return type is None

    def pause(self):
        if self.q is not None:
            children = len(active_children())
            getLogger().debug(
                "ControlHandler pausing {} children".format(children))
            map(self.q.put, [{'pause': True}] * children)
        else:

# Path: lacli/log.py
# def getLogger(logger='lacli'):
#     return lacore.log.getLogger(logger)
# 
# Path: lacli/exceptions.py
# class PauseEvent(BaseAppException):
#     msg = "Paused"


# Path: lacli/control.py
from lacli.log import getLogger
from lacli.exceptions import PauseEvent
from multiprocessing import Queue, active_children
from Queue import Empty



class ControlHandler(object):

    def __init__(self):
        self.q = None

    def __enter__(self):
        self.q = Queue()
        controlByQueue(self.q)
        return self.q

    def __exit__(self, type, value, traceback):
        getLogger().debug("control handler exiting.")
        if type == KeyboardInterrupt:
            getLogger().debug("upload pausing.")
            self.pause()
            type = None
        stopControlByQueue()
        return type is None

    def pause(self):
        if self.q is not None:
            children = len(active_children())
            getLogger().debug(
                "ControlHandler pausing {} children".format(children))
            map(self.q.put, [{'pause': True}] * children)
        else:

            getLogger().debug(