jenkins-bot merged this change.
[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(-)
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:
To view, visit change 430877. To unsubscribe, visit settings.