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(

--
To view, visit https://gerrit.wikimedia.org/r/606172
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I4dbb78efa546067dc9916476c9f576b92fb8d921
Gerrit-Change-Number: 606172
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to