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

Proposed by Chad Miller
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~cmiller/desktopcouch/get-port-without-fd-race
Merge into: lp:desktopcouch
Diff against target: 25 lines (+10/-3)
1 file modified
desktopcouch/__init__.py (+10/-3)
To merge this branch: bzr merge lp:~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.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
=== modified file 'desktopcouch/__init__.py'
--- desktopcouch/__init__.py 2009-11-20 23:36:40 +0000
+++ desktopcouch/__init__.py 2010-02-08 14:37:12 +0000
@@ -70,11 +70,18 @@
7070
71 # enumerate the process' file descriptors71 # enumerate the process' file descriptors
72 fd_dir = os.path.join(proc_dir, 'fd')72 fd_dir = os.path.join(proc_dir, 'fd')
73 fd_paths = list()
73 try:74 try:
74 fd_paths = [os.readlink(os.path.join(fd_dir, fd))75 for dirent in os.listdir(fd_dir):
75 for fd in os.listdir(fd_dir)]76 try:
77 dirent_path = os.path.join(fd_dir, dirent)
78 fd_paths.append(os.readlink(dirent_path))
79 except OSError:
80 log.debug("dirent %r disappeared before we could read it. " %
81 (dirent_path,))
82 continue
76 except OSError:83 except OSError:
77 log.error("Unable to find file descriptors in /proc")84 log.exception("Unable to find file descriptors in /proc")
78 raise RuntimeError("Unable to find file descriptors in /proc")85 raise RuntimeError("Unable to find file descriptors in /proc")
7986
80 # identify socket fds87 # identify socket fds

Subscribers

People subscribed via source and target branches