jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/430877 )
Change subject: [IMPR] Simplify Throttle.drop() ......................................................................
[IMPR] Simplify Throttle.drop()
- drop() is exited by the first IOError exception. It does not make any sense to have some code parts in the else clause and whereas other parts of the same logic are dedented. The else is superfluous here.
Change-Id: I65be0367e04dd30be646348c70d94b6912c3282d --- M pywikibot/throttle.py 1 file changed, 17 insertions(+), 16 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index ab56ac7..abba04f 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -204,22 +204,23 @@ lines = f.readlines() except IOError: return - else: - now = time.time() - for line in lines: - try: - line = line.split(' ') - this_pid = int(line[0]) - ptime = int(line[1].split('.')[0]) - this_site = line[2].rstrip() - except (IndexError, ValueError): - # Sometimes the file gets corrupted ignore that line - continue - if now - ptime <= self.releasepid \ - and this_pid != pid: - processes.append({'pid': this_pid, - 'time': ptime, - 'site': this_site}) + + now = time.time() + for line in lines: + try: + line = line.split(' ') + this_pid = int(line[0]) + ptime = int(line[1].split('.')[0]) + this_site = line[2].rstrip() + except (IndexError, ValueError): + # Sometimes the file gets corrupted ignore that line + continue + if now - ptime <= self.releasepid \ + and this_pid != pid: + processes.append({'pid': this_pid, + 'time': ptime, + 'site': this_site}) + processes.sort(key=lambda p: p['pid']) try: with open(self.ctrlfilename, 'w') as f:
pywikibot-commits@lists.wikimedia.org