ArielGlenn has submitted this change and it was merged. Change subject: scheduler: move generation of unique id string out to the module ......................................................................
scheduler: move generation of unique id string out to the module We need this to get called once only, so it's consistent across the entire script run. It therefore makes sense for the same code block that instantiates the Scheduler to call this first, which means it should live outside of any class. also fix for real the file closing on HUP so we actually check that we are not closing the descriptors for stdin/out/err Change-Id: Ia341cc0c61a7eacd195dd92cffcf5516150f0496 --- M xmldumps-backup/dumpscheduler.py 1 file changed, 11 insertions(+), 3 deletions(-) Approvals: ArielGlenn: Looks good to me, approved jenkins-bot: Verified diff --git a/xmldumps-backup/dumpscheduler.py b/xmldumps-backup/dumpscheduler.py index 05edc28..376d6b7 100644 --- a/xmldumps-backup/dumpscheduler.py +++ b/xmldumps-backup/dumpscheduler.py @@ -242,6 +242,14 @@ str(self.free_slots), str(self.total_slots)) +def get_my_id(): + ''' + return an id string associated with this pid + ''' + return "%s%d%s" % (time.strftime("%Y%m%d%H%M%S", time.gmtime()), + os.getpid(), os.geteuid()) + + class Scheduler(object): ''' handle running a sequence of commands, each command possibly to @@ -263,8 +271,7 @@ self.input = file_p self.commands = [] self.pid = os.getpid() - self.my_id = "%s%d%s" % (time.strftime("%Y%m%d%H%M%S", time.gmtime()), - self.pid, os.geteuid()) + self.my_id = get_my_id() self.my_prefix = 'PYMGR_ID' self.formatvars = format_convert(formatvars) self.cacher = Cacher(cache, self.my_id, restore, rerun) @@ -293,7 +300,8 @@ pass for filedesc in reversed(range(os.sysconf('SC_OPEN_MAX'))): - if filedesc not in [sys.__stdin__, sys.__stdout__, sys.__stderr__]: + if filedesc not in [sys.__stdin__.fileno(), sys.__stdout__.fileno(), + sys.__stderr__.fileno()]: try: os.close(filedesc) except (IOError, OSError): -- To view, visit https://gerrit.wikimedia.org/r/306212 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia341cc0c61a7eacd195dd92cffcf5516150f0496 Gerrit-PatchSet: 2 Gerrit-Project: operations/dumps Gerrit-Branch: master Gerrit-Owner: ArielGlenn <ar...@wikimedia.org> Gerrit-Reviewer: ArielGlenn <ar...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits