Merge lp:~stefanor/ibid/log-race-655645 into lp:~ibid-core/ibid/old-trunk-1.6

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 975
Merged at revision: 987
Proposed branch: lp:~stefanor/ibid/log-race-655645
Merge into: lp:~ibid-core/ibid/old-trunk-1.6
Diff against target: 25 lines (+9/-5)
1 file modified
ibid/plugins/log.py (+9/-5)
To merge this branch: bzr merge lp:~stefanor/ibid/log-race-655645
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Max Rabkin Approve
Review via email: mp+38048@code.launchpad.net

Commit message

Logs in logs might not be in recent_logs (we love you, GC)

Description of the change

I almost backported an OrderedDict with WeakValue support, then I realised the obvious solution...

To post a comment you must log in.
Revision history for this message
Max Rabkin (max-rabkin) :
review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/log.py'
2--- ibid/plugins/log.py 2010-10-01 14:16:38 +0000
3+++ ibid/plugins/log.py 2010-10-09 14:30:56 +0000
4@@ -117,12 +117,16 @@
5 break
6 else:
7 chmod(filename, int(self.private_mode, 8))
8+ else:
9+ # recent_logs is an LRU cache, we'll be moving log to the
10+ # front of the queue, if it's in the queue.
11+ # It might not be, GCs are fickle LP: 655645
12+ try:
13+ self.recent_logs.remove(log)
14+ except ValueError:
15+ pass
16
17- if len(self.recent_logs) > self.fd_cache:
18- self.recent_logs.pop()
19- else:
20- self.recent_logs.remove(log)
21- self.recent_logs.insert(0, log)
22+ self.recent_logs = [log] + self.recent_logs[:self.fd_cache - 1]
23 return log
24 finally:
25 self.lock.release()

Subscribers

People subscribed via source and target branches