jenkins-bot merged this change.
Revert "[IMPR] Always close files finally in throttle.py"
Fails if file cannot be opened:
f.close()
UnboundLocalError: local variable 'f' referenced before assignment
This reverts commit 98fd8fb74998c08a9f1fac4031297bb007848b57.
Change-Id: I044dcf3ff44153d2e754f8b85f03aa16f33fbaf3
---
M pywikibot/throttle.py
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 047e67c..91b3318 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -121,7 +121,6 @@
'site': this_site})
if not pid and this_pid >= my_pid:
my_pid = this_pid + 1 # next unused process id
- finally:
f.close()
if not pid:
@@ -132,12 +131,13 @@
'site': mysite})
processes.sort(key=lambda p: (p['pid'], p['site']))
try:
- with open(self.ctrlfilename, 'w') as f:
- for p in processes:
- f.write('{pid} {time} {site}\n'.format(**p))
+ f = open(self.ctrlfilename, 'w')
+ for p in processes:
+ f.write('%(pid)s %(time)s %(site)s\n' % p)
except IOError:
pass
-
+ else:
+ f.close()
self.process_multiplicity = count
pywikibot.log(
'Found {0} {1} processes running, including this one.'.format(
To view, visit change 606683. To unsubscribe, or for help writing mail filters, visit settings.