Skip to content

Commit

Permalink
use fileno comparison only as an alternative and when available
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Nov 11, 2014
1 parent 9e24bcf commit 270173f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions clients/rospy/src/rospy/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,15 @@ def _remove_connection(self, connections, c):
pass
# while c might be a rospy.impl.tcpros_base.TCPROSTransport instance
# connections might only contain the rospy.impl.tcpros_pubsub.QueuedConnection proxy
# therefore finding the "right" connection is more difficult then
# if c in connections
matching_connections = [
conn for conn in connections if conn.fileno() == c.fileno()]
if matching_connections:
connections.remove(matching_connections[0])
# finding the "right" connection is more difficult then
if c in connections:
connections.remove(c)
# therefore additionally check for fileno equality if available
elif c.fileno():
matching_connections = [
conn for conn in connections if conn.fileno() == c.fileno()]
if len(matching_connections) == 1:
connections.remove(matching_connections[0])

def add_connection(self, c):
"""
Expand Down

0 comments on commit 270173f

Please sign in to comment.