コード例 #1
0
    def activate(self, config):
        """Create a new cloned workspace from a configuration.

        This replaces any existing clone, cleaning up its resources.
        """
        new_workspace = ClonedWorkspace(config.cloning_config)

        self.cleanup()

        self._config = config
        self._workspace = new_workspace
コード例 #2
0
def _ensure_workspace(config):
    global _workspace
    global _pid

    if _workspace is not None:
        assert _pid == os.getpid()
        return

    log.info('Initialize celery4 workspace in PID %s', os.getpid())
    _workspace = ClonedWorkspace(config.cloning_config)
    _pid = os.getpid()

    os.chdir(_workspace.clone_dir)
コード例 #3
0
ファイル: local.py プロジェクト: willfrey/cosmic-ray
def _initialize_worker(config):
    # pylint: disable=global-statement
    global _workspace
    global _config
    assert _workspace is None
    assert _config is None

    _config = config

    log.info('Initialize local-git worker in PID %s', os.getpid())
    _workspace = ClonedWorkspace(config.cloning_config)

    # Register a finalizer
    multiprocessing.util.Finalize(_workspace,
                                  _workspace.cleanup,
                                  exitpriority=16)
コード例 #4
0
def _ensure_workspace(config):
    """This ensures that there is a ClonedWorkspace for the current
    process.
    """
    global _workspace
    global _pid

    if _workspace is not None:
        assert _pid == os.getpid()
        return

    log.info('Initialize celery4 workspace in PID %s', os.getpid())
    _workspace = ClonedWorkspace(config.cloning_config)
    _pid = os.getpid()

    # TODO: Consider a signal handler or something to know when to clean up the cloned workspace.

    os.chdir(_workspace.clone_dir)