1 |
commit: c02b0e535a4cfe4dc0a3c3d07124b8dfa5d4f9a5 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 8 05:03:32 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 8 06:08:45 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c02b0e53 |
7 |
|
8 |
QueueScheduler: tweak timeout handling |
9 |
|
10 |
--- |
11 |
pym/_emerge/QueueScheduler.py | 27 ++++++++++++++------------- |
12 |
1 files changed, 14 insertions(+), 13 deletions(-) |
13 |
|
14 |
diff --git a/pym/_emerge/QueueScheduler.py b/pym/_emerge/QueueScheduler.py |
15 |
index 91a2831..e115ba1 100644 |
16 |
--- a/pym/_emerge/QueueScheduler.py |
17 |
+++ b/pym/_emerge/QueueScheduler.py |
18 |
@@ -1,8 +1,6 @@ |
19 |
-# Copyright 1999-2011 Gentoo Foundation |
20 |
+# Copyright 1999-2012 Gentoo Foundation |
21 |
# Distributed under the terms of the GNU General Public License v2 |
22 |
|
23 |
-import time |
24 |
- |
25 |
from _emerge.PollScheduler import PollScheduler |
26 |
|
27 |
class QueueScheduler(PollScheduler): |
28 |
@@ -36,25 +34,28 @@ class QueueScheduler(PollScheduler): |
29 |
|
30 |
def run(self, timeout=None): |
31 |
|
32 |
- timeout_id = None |
33 |
+ timeout_callback = None |
34 |
if timeout is not None: |
35 |
def timeout_callback(): |
36 |
- raise StopIteration() |
37 |
- timeout_id = self._timeout_add(timeout, timeout_callback) |
38 |
+ timeout_callback.timed_out = True |
39 |
+ return False |
40 |
+ timeout_callback.timed_out = False |
41 |
+ timeout_callback.timeout_id = self._timeout_add( |
42 |
+ timeout, timeout_callback) |
43 |
|
44 |
try: |
45 |
|
46 |
- while self._schedule(): |
47 |
+ while not (timeout_callback is not None and |
48 |
+ timeout_callback.timed_out) and self._schedule(): |
49 |
self._iteration() |
50 |
|
51 |
- while self._running_job_count(): |
52 |
+ while not (timeout_callback is not None and |
53 |
+ timeout_callback.timed_out) and self._running_job_count(): |
54 |
self._iteration() |
55 |
|
56 |
- except StopIteration: |
57 |
- pass |
58 |
- |
59 |
- if timeout_id is not None: |
60 |
- self._unregister(timeout_id) |
61 |
+ finally: |
62 |
+ if timeout_callback is not None: |
63 |
+ self._unregister(timeout_callback.timeout_id) |
64 |
|
65 |
def _schedule_tasks(self): |
66 |
""" |