Gentoo Logo
Gentoo Spaceship

Installation:
Gentoo Handbook
Installation Docs

Documentation:
Home
Listing
About Gentoo
Philosophy
Social Contract

Resources:
Bug Tracker
Developer List
Discussion Forums
Gentoo BitTorrents
Gentoo Linux Enhancement Proposals
IRC Channels
Mailing Lists
Mirrors
Name and Logo Guidelines
Online Package Database
Security Announcements
Staffing Needs
Supporting Vendors
View our CVS

Graphics:
Logos and themes
Icons
ScreenShots

Miscellaneous Resources:
Gentoo Linux Store
Gentoo-hosted projects
IBM dW/Intel article archive




List Archive: gentoo-commits
Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-commits@g.o
From: "Zac Medico (zmedico)" <zmedico@g.o>
Subject: portage r10943 - main/trunk/pym/_emerge
Date: Sat, 05 Jul 2008 13:19:02 +0000

 1.1

Author: zmedico
Date: 2008-07-05 13:19:01 +0000 (Sat, 05 Jul 2008)
New Revision: 10943

Modified:
   main/trunk/pym/_emerge/__init__.py
Log:
Split out common code from CompositeTask and EbuildExecuter into a new
CompositeTask class and rename the old CompositeTask class to TaskSequence.


Modified: main/trunk/pym/_emerge/__init__.py
===================================================================
--- main/trunk/pym/_emerge/__init__.py	2008-07-05 13:06:47 UTC (rev 10942)
+++ main/trunk/pym/_emerge/__init__.py	2008-07-05 13:19:01 UTC (rev 10943)
@@ -1499,29 +1499,13 @@
 			self._exit_listeners = None
 
 class CompositeTask(AsynchronousTask):
-	"""
-	A collection of tasks that executes sequentially. Each task
-	must have a _set_returncode() method that can be wrapped as
-	a means to trigger movement from one task to the next.
-	"""
 
-	__slots__ = ("scheduler",) + ("_current_task", "_task_queue")
+	__slots__ = ("scheduler",) + ("_current_task",)
 
-	def __init__(self, **kwargs):
-		AsynchronousTask.__init__(self, **kwargs)
-		self._task_queue = deque()
-
-	def add(self, task):
-		self._task_queue.append(task)
-
-	def start(self):
-		self._start_next_task()
-
 	def isAlive(self):
 		return self._current_task is not None
 
 	def cancel(self):
-		self._task_queue.clear()
 		self.cancelled = True
 		if self._current_task is not None:
 			self._current_task.cancel()
@@ -1532,12 +1516,36 @@
 			task = self._current_task
 			if task is None:
 				break
-			self.scheduler.schedule(task.reg_id)
+			if hasattr(task, "reg_id"):
+				self.scheduler.schedule(task.reg_id)
 			task.wait()
 
 		self._wait_hook()
 		return self.returncode
 
+class TaskSequence(CompositeTask):
+	"""
+	A collection of tasks that executes sequentially. Each task
+	must have a _set_returncode() method that can be wrapped as
+	a means to trigger movement from one task to the next.
+	"""
+
+	__slots__ = ("_task_queue",)
+
+	def __init__(self, **kwargs):
+		AsynchronousTask.__init__(self, **kwargs)
+		self._task_queue = deque()
+
+	def add(self, task):
+		self._task_queue.append(task)
+
+	def start(self):
+		self._start_next_task()
+
+	def cancel(self):
+		self._task_queue.clear()
+		CompositeTask.cancel(self)
+
 	def _start_next_task(self):
 		self._current_task = self._task_queue.popleft()
 		task = self._current_task
@@ -1945,9 +1953,9 @@
 				self.unlock()
 		return os.EX_OK
 
-class EbuildExecuter(AsynchronousTask):
+class EbuildExecuter(CompositeTask):
 
-	__slots__ = ("pkg", "scheduler", "settings") + ("_current_task",)
+	__slots__ = ("pkg", "scheduler", "settings")
 
 	_phases = ("setup", "unpack", "compile", "test", "install")
 
@@ -1986,7 +1994,7 @@
 			2 : sys.stderr.fileno(),
 		}
 
-		ebuild_phases = CompositeTask(scheduler=scheduler)
+		ebuild_phases = TaskSequence(scheduler=scheduler)
 
 		for phase in self._phases:
 			ebuild_phases.add(EbuildPhase(fd_pipes=fd_pipes,
@@ -2001,27 +2009,6 @@
 		self.returncode = ebuild_phases.returncode
 		self._current_task = None
 
-	def isAlive(self):
-		return self._current_task is not None
-
-	def cancel(self):
-		self.cancelled = True
-		if self._current_task is not None:
-			self._current_task.cancel()
-
-	def wait(self):
-
-		while True:
-			task = self._current_task
-			if task is None:
-				break
-			if hasattr(task, "reg_id"):
-				self.scheduler.schedule(task.reg_id)
-			task.wait()
-
-		self._wait_hook()
-		return self.returncode
-
 class EbuildPhase(SubProcess):
 
 	__slots__ = ("fd_pipes", "phase", "pkg",

-- 
gentoo-commits@g.o mailing list


Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
portage r10942 - main/trunk/pym/_emerge
Next by thread:
portage r10945 - main/trunk/pym/_emerge
Previous by date:
gentoo-x86 commit in profiles: ChangeLog profiles.desc
Next by date:
gentoo-x86 commit in dev-util/mercurial: ChangeLog mercurial-1.0.1-r2.ebuild


Oct 15, 2008

Donate to support our development efforts.

Gentoo Centric Hosting: vr.org

VR Hosted

Tek Alchemy

Tek Alchemy

SevenL.net

SevenL.net

php|architect

php|architect

Copyright 2001-2007 Gentoo Foundation, Inc. Questions, Comments? Email www@gentoo.org.