From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/
Date: Sat, 29 Dec 2012 07:45:46 +0000 (UTC) [thread overview]
Message-ID: <1356767079.d6bde84bd02aba99bbf7ee5a6a0e55d2be4216ff.zmedico@gentoo> (raw)
commit: d6bde84bd02aba99bbf7ee5a6a0e55d2be4216ff
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 29 07:44:39 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 29 07:44:39 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d6bde84b
Use run_main_scheduler where possible.
---
bin/egencache | 62 +++++------------------------------------------
pym/_emerge/actions.py | 32 +++---------------------
2 files changed, 11 insertions(+), 83 deletions(-)
diff --git a/bin/egencache b/bin/egencache
index 79a996d..110c47d 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -50,6 +50,7 @@ from portage.cache.cache_errors import CacheError, StatCollision
from portage.manifest import guessManifestFileType
from portage.package.ebuild._parallel_manifest.ManifestScheduler import ManifestScheduler
from portage.util import cmp_sort_key, writemsg_level
+from portage.util._async.run_main_scheduler import run_main_scheduler
from portage.util._eventloop.global_event_loop import global_event_loop
from portage import cpv_getkey
from portage.dep import Atom, isjustname
@@ -357,34 +358,9 @@ class GenCache(object):
level=logging.ERROR, noiselevel=-1)
def run(self):
-
- received_signal = []
-
- def sighandler(signum, frame):
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- signal.signal(signal.SIGTERM, signal.SIG_IGN)
- self._regen.terminate()
- received_signal.append(128 + signum)
-
- earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler)
- earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
-
- try:
- self._regen.start()
- self._regen.wait()
- finally:
- # Restore previous handlers
- if earlier_sigint_handler is not None:
- signal.signal(signal.SIGINT, earlier_sigint_handler)
- else:
- signal.signal(signal.SIGINT, signal.SIG_DFL)
- if earlier_sigterm_handler is not None:
- signal.signal(signal.SIGTERM, earlier_sigterm_handler)
- else:
- signal.signal(signal.SIGTERM, signal.SIG_DFL)
-
- if received_signal:
- sys.exit(received_signal[0])
+ signum = run_main_scheduler(self._regen)
+ if signum is not None:
+ sys.exit(128 + signum)
self.returncode |= self._regen.returncode
@@ -1058,33 +1034,9 @@ def egencache_main(args):
max_load=options.load_average,
event_loop=event_loop)
- received_signal = []
-
- def sighandler(signum, frame):
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- signal.signal(signal.SIGTERM, signal.SIG_IGN)
- received_signal.append(128 + signum)
- scheduler.terminate()
-
- earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler)
- earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler)
-
- try:
- scheduler.start()
- scheduler.wait()
- finally:
- # Restore previous handlers
- if earlier_sigint_handler is not None:
- signal.signal(signal.SIGINT, earlier_sigint_handler)
- else:
- signal.signal(signal.SIGINT, signal.SIG_DFL)
- if earlier_sigterm_handler is not None:
- signal.signal(signal.SIGTERM, earlier_sigterm_handler)
- else:
- signal.signal(signal.SIGTERM, signal.SIG_DFL)
-
- if received_signal:
- sys.exit(received_signal[0])
+ signum = run_main_scheduler(scheduler)
+ if signum is not None:
+ sys.exit(128 + signum)
if options.tolerant:
ret.append(os.EX_OK)
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 982197b..a498ae4 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -55,6 +55,7 @@ from portage._sets.base import InternalPackageSet
from portage.util import cmp_sort_key, writemsg, varexpand, \
writemsg_level, writemsg_stdout
from portage.util.digraph import digraph
+from portage.util._async.run_main_scheduler import run_main_scheduler
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
@@ -1951,35 +1952,10 @@ def action_regen(settings, portdb, max_jobs, max_load):
regen = MetadataRegen(portdb, max_jobs=max_jobs,
max_load=max_load, main=True)
- received_signal = []
- def emergeexitsig(signum, frame):
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- signal.signal(signal.SIGTERM, signal.SIG_IGN)
- portage.util.writemsg("\n\nExiting on signal %(signal)s\n" % \
- {"signal":signum})
- regen.terminate()
- received_signal.append(128 + signum)
-
- earlier_sigint_handler = signal.signal(signal.SIGINT, emergeexitsig)
- earlier_sigterm_handler = signal.signal(signal.SIGTERM, emergeexitsig)
-
- try:
- regen.start()
- regen.wait()
- finally:
- # Restore previous handlers
- if earlier_sigint_handler is not None:
- signal.signal(signal.SIGINT, earlier_sigint_handler)
- else:
- signal.signal(signal.SIGINT, signal.SIG_DFL)
- if earlier_sigterm_handler is not None:
- signal.signal(signal.SIGTERM, earlier_sigterm_handler)
- else:
- signal.signal(signal.SIGTERM, signal.SIG_DFL)
-
- if received_signal:
- sys.exit(received_signal[0])
+ signum = run_main_scheduler(regen)
+ if signum is not None:
+ sys.exit(128 + signum)
portage.writemsg_stdout("done!\n")
return regen.returncode
next reply other threads:[~2012-12-29 7:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-29 7:45 Zac Medico [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-04-30 19:28 [gentoo-commits] proj/portage:master commit in: bin/, pym/_emerge/ Zac Medico
2018-03-28 6:52 Zac Medico
2015-09-28 16:08 Zac Medico
2013-12-27 18:06 Arfrever Frehtes Taifersar Arahesis
2013-08-03 0:38 Zac Medico
2012-10-14 21:59 Zac Medico
2012-10-06 18:11 Zac Medico
2012-10-06 18:05 Zac Medico
2012-09-15 16:53 Zac Medico
2012-07-18 21:38 Zac Medico
2012-03-25 23:20 Zac Medico
2011-12-10 3:23 Zac Medico
2011-10-29 3:20 Zac Medico
2011-10-28 20:13 Zac Medico
2011-02-22 2:51 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356767079.d6bde84bd02aba99bbf7ee5a6a0e55d2be4216ff.zmedico@gentoo \
--to=zmedico@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox