Merge lp://qastaging/~cmiller/desktopcouch/get-port-without-fd-race into lp://qastaging/desktopcouch

Proposed by Chad Miller
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: not available
Merged at revision: not available
Proposed branch: lp://qastaging/~cmiller/desktopcouch/get-port-without-fd-race
Merge into: lp://qastaging/desktopcouch
Diff against target: 25 lines (+10/-3)
1 file modified
desktopcouch/__init__.py (+10/-3)
To merge this branch: bzr merge lp://qastaging/~cmiller/desktopcouch/get-port-without-fd-race
Reviewer Review Type Date Requested Status
John O'Brien (community) Approve
Stuart Langridge (community) Approve
Review via email: mp+18840@code.qastaging.launchpad.net

Commit message

Fix a more obscure find_port bug in which reading all entries in a directory and then inspecting each entry fails, because an entry no longer exists.

To post a comment you must log in.
Revision history for this message
Stuart Langridge (sil) :
review: Approve
Revision history for this message
John O'Brien (jdobrien) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'desktopcouch/__init__.py'
2--- desktopcouch/__init__.py 2009-11-20 23:36:40 +0000
3+++ desktopcouch/__init__.py 2010-02-08 14:37:12 +0000
4@@ -70,11 +70,18 @@
5
6 # enumerate the process' file descriptors
7 fd_dir = os.path.join(proc_dir, 'fd')
8+ fd_paths = list()
9 try:
10- fd_paths = [os.readlink(os.path.join(fd_dir, fd))
11- for fd in os.listdir(fd_dir)]
12+ for dirent in os.listdir(fd_dir):
13+ try:
14+ dirent_path = os.path.join(fd_dir, dirent)
15+ fd_paths.append(os.readlink(dirent_path))
16+ except OSError:
17+ log.debug("dirent %r disappeared before we could read it. " %
18+ (dirent_path,))
19+ continue
20 except OSError:
21- log.error("Unable to find file descriptors in /proc")
22+ log.exception("Unable to find file descriptors in /proc")
23 raise RuntimeError("Unable to find file descriptors in /proc")
24
25 # identify socket fds

Subscribers

People subscribed via source and target branches