summaryrefslogtreecommitdiffstats
path: root/pym/portage/dbapi/_MergeProcess.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-11-11 23:25:04 -0800
committerZac Medico <zmedico@gentoo.org>2010-11-11 23:25:04 -0800
commite1b167ef9a6c66d068c5dae4ae5b8b7a0cd89add (patch)
treeebe617ee282fa8af2cc0c23e306ffb303f953856 /pym/portage/dbapi/_MergeProcess.py
parentac5f9017bb621d1deaab932204362bf918ffd088 (diff)
downloadportage-e1b167ef9a6c66d068c5dae4ae5b8b7a0cd89add.tar.gz
portage-e1b167ef9a6c66d068c5dae4ae5b8b7a0cd89add.tar.bz2
portage-e1b167ef9a6c66d068c5dae4ae5b8b7a0cd89add.zip
Merge package files in a subprocess.
This allows the Scheduler to run in the main thread while files are moved or copied asynchronously.
Diffstat (limited to 'pym/portage/dbapi/_MergeProcess.py')
-rw-r--r--pym/portage/dbapi/_MergeProcess.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/pym/portage/dbapi/_MergeProcess.py b/pym/portage/dbapi/_MergeProcess.py
new file mode 100644
index 000000000..b5af7142c
--- /dev/null
+++ b/pym/portage/dbapi/_MergeProcess.py
@@ -0,0 +1,41 @@
+# Copyright 2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import portage
+from portage import os
+from _emerge.SpawnProcess import SpawnProcess
+
+class MergeProcess(SpawnProcess):
+ """
+ Merge package files in a subprocess, so the Scheduler can run in the
+ main thread while files are moved or copied asynchronously.
+ """
+
+ __slots__ = ('cfgfiledict', 'conf_mem_file', \
+ 'destroot', 'dblink', 'srcroot',)
+
+ def _spawn(self, args, fd_pipes=None, **kwargs):
+ """
+ Fork a subprocess, apply local settings, and call
+ dblink._merge_process().
+ """
+
+ pid = os.fork()
+ if pid != 0:
+ portage.process.spawned_pids.append(pid)
+ return [pid]
+
+ portage.process._setup_pipes(fd_pipes)
+
+ portage.output.havecolor = self.dblink.settings.get('NOCOLOR') \
+ not in ('yes', 'true')
+
+ # In this subprocess we want dblink._display_merge() to use
+ # stdout/stderr directly since they are pipes. This behavior
+ # is triggered when dblink._scheduler is None.
+ self.dblink._scheduler = None
+
+ rval = self.dblink._merge_process(self.srcroot, self.destroot,
+ self.cfgfiledict, self.conf_mem_file)
+
+ os._exit(rval)