jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/606172 )
Change subject: [IMPR] Always close files finally in throttle.py ......................................................................
[IMPR] Always close files finally in throttle.py
- move close() statement to finally section in checkMultiplicity() - use with statement in drop()
Change-Id: I4dbb78efa546067dc9916476c9f576b92fb8d921 --- M pywikibot/throttle.py 1 file changed, 5 insertions(+), 5 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index 91b3318..047e67c 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -121,6 +121,7 @@ '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: @@ -131,13 +132,12 @@ 'site': mysite}) processes.sort(key=lambda p: (p['pid'], p['site'])) try: - f = open(self.ctrlfilename, 'w') - for p in processes: - f.write('%(pid)s %(time)s %(site)s\n' % p) + with open(self.ctrlfilename, 'w') as f: + for p in processes: + f.write('{pid} {time} {site}\n'.format(**p)) except IOError: pass - else: - f.close() + self.process_multiplicity = count pywikibot.log( 'Found {0} {1} processes running, including this one.'.format(