SchedulerInterface suffices for all of these cases.
EventLoop(main=False) is used for thread safety where
API consumers may be using threads.
from portage.util import cmp_sort_key, writemsg, \
writemsg_level, writemsg_stdout
from portage.util.digraph import digraph
+from portage.util._async.SchedulerInterface import SchedulerInterface
+from portage.util._eventloop.global_event_loop import global_event_loop
from portage._global_updates import _global_updates
from _emerge.clear_caches import clear_caches
from _emerge.is_valid_package_atom import is_valid_package_atom
from _emerge.MetadataRegen import MetadataRegen
from _emerge.Package import Package
-from _emerge.PollScheduler import PollScheduler
from _emerge.ProgressHandler import ProgressHandler
from _emerge.RootConfig import RootConfig
from _emerge.Scheduler import Scheduler
# Use the same logic as the Scheduler class to trigger redirection
# of ebuild pkg_prerm/postrm phase output to logs as appropriate
# for options such as --jobs, --quiet and --quiet-build.
- sched = PollScheduler(main=True)
max_jobs = opts.get("--jobs", 1)
- sched._background = (max_jobs is True or max_jobs > 1 or
+ background = (max_jobs is True or max_jobs > 1 or
"--quiet" in opts or opts.get("--quiet-build") == "y")
+ sched_iface = SchedulerInterface(global_event_loop(),
+ is_background=lambda: background)
- if sched._background:
+ if background:
settings.unlock()
settings["PORTAGE_BACKGROUND"] = "1"
settings.backup_changes("PORTAGE_BACKGROUND")
ordered = action == 'unmerge'
rval = unmerge(trees[settings['EROOT']]['root_config'], opts, action,
valid_atoms, ldpath_mtimes, ordered=ordered,
- scheduler=sched.sched_iface)
+ scheduler=sched_iface)
else:
rval = action_depclean(settings, trees, ldpath_mtimes,
opts, action, valid_atoms, spinner,
- scheduler=sched.sched_iface)
+ scheduler=sched_iface)
return rval
'portage.util.movefile:movefile',
'portage.util._dyn_libs.PreservedLibsRegistry:PreservedLibsRegistry',
'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap',
+ 'portage.util._async.SchedulerInterface:SchedulerInterface',
'portage.util._eventloop.EventLoop:EventLoop',
'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,vercmp,' + \
'_pkgsplit@pkgsplit,_pkg_str',
from _emerge.EbuildBuildDir import EbuildBuildDir
from _emerge.EbuildPhase import EbuildPhase
from _emerge.emergelog import emergelog
-from _emerge.PollScheduler import PollScheduler
from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
from _emerge.SpawnProcess import SpawnProcess
if self._scheduler is None:
# We create a scheduler instance and use it to
# log unmerge output separately from merge output.
- self._scheduler = PollScheduler().sched_iface
+ self._scheduler = SchedulerInterface(EventLoop(main=False))
if self.settings.get("PORTAGE_BACKGROUND") == "subprocess":
if self.settings.get("PORTAGE_BACKGROUND_UNMERGE") == "1":
self.settings["PORTAGE_BACKGROUND"] = "1"
self.lockdb()
self.vartree.dbapi._bump_mtime(self.mycpv)
if self._scheduler is None:
- self._scheduler = PollScheduler().sched_iface
+ self._scheduler = SchedulerInterface(EventLoop(main=False))
try:
retval = self.treewalk(mergeroot, myroot, inforoot, myebuild,
cleanup=cleanup, mydbapi=mydbapi, prev_mtimes=prev_mtimes,
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import tempfile
from portage.package.ebuild.config import config
from portage.package.ebuild.doebuild import doebuild_environment
from portage.package.ebuild.prepare_build_dirs import prepare_build_dirs
+from portage.util._async.SchedulerInterface import SchedulerInterface
+from portage.util._eventloop.EventLoop import EventLoop
from _emerge.EbuildPhase import EbuildPhase
-from _emerge.PollScheduler import PollScheduler
def spawn_nofetch(portdb, ebuild_path, settings=None):
"""
prepare_build_dirs(settings=settings)
ebuild_phase = EbuildPhase(background=False,
- phase='nofetch', scheduler=PollScheduler().sched_iface,
+ phase='nofetch',
+ scheduler=SchedulerInterface(EventLoop(main=False)),
settings=settings)
ebuild_phase.start()
ebuild_phase.wait()
'portage.dep._slot_operator:evaluate_slot_operator_equal_deps',
'portage.package.ebuild._spawn_nofetch:spawn_nofetch',
'portage.util._desktop_entry:validate_desktop_entry',
+ 'portage.util._async.SchedulerInterface:SchedulerInterface',
'portage.util._eventloop.EventLoop:EventLoop',
'portage.util.ExtractKernelVersion:ExtractKernelVersion'
)
from _emerge.EbuildPhase import EbuildPhase
from _emerge.EbuildSpawnProcess import EbuildSpawnProcess
from _emerge.Package import Package
-from _emerge.PollScheduler import PollScheduler
from _emerge.RootConfig import RootConfig
_unsandboxed_phases = frozenset([
return _doebuild_spawn(phase, settings, actionmap=actionmap, **kwargs)
ebuild_phase = EbuildPhase(actionmap=actionmap, background=False,
- phase=phase, scheduler=PollScheduler().sched_iface,
+ phase=phase, scheduler=SchedulerInterface(EventLoop(main=False)),
settings=settings)
ebuild_phase.start()
ebuild_phase.wait()
proc = EbuildSpawnProcess(
background=False, args=mystring,
- scheduler=PollScheduler().sched_iface, spawn_func=spawn_func,
+ scheduler=SchedulerInterface(EventLoop(main=False)),
+ spawn_func=spawn_func,
settings=mysettings, **keywords)
proc.start()
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage import os
from portage.package.ebuild.doebuild import spawn as doebuild_spawn
from portage.tests import TestCase
from portage.tests.resolver.ResolverPlayground import ResolverPlayground
+from portage.util._async.SchedulerInterface import SchedulerInterface
+from portage.util._eventloop.global_event_loop import global_event_loop
from _emerge.EbuildPhase import EbuildPhase
from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
from _emerge.Package import Package
-from _emerge.PollScheduler import PollScheduler
class DoebuildSpawnTestCase(TestCase):
"""
# has been sourced already.
open(os.path.join(settings['T'], 'environment'), 'wb').close()
- scheduler = PollScheduler().sched_iface
+ scheduler = SchedulerInterface(global_event_loop())
for phase in ('_internal_test',):
# Test EbuildSpawnProcess by calling doebuild.spawn() with