Skip to content

Commit

Permalink
curl_httpclient: don't call remove_handler if we never added it.
Browse files Browse the repository at this point in the history
Re-order IOLoop and self._fds operations for consistency.
  • Loading branch information
bdarnell committed Dec 7, 2012
1 parent c6593a3 commit 6cf1fa1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tornado/curl_httpclient.py
Expand Up @@ -96,17 +96,18 @@ def _handle_socket(self, event, fd, multi, data):
pycurl.POLL_INOUT: ioloop.IOLoop.READ | ioloop.IOLoop.WRITE pycurl.POLL_INOUT: ioloop.IOLoop.READ | ioloop.IOLoop.WRITE
} }
if event == pycurl.POLL_REMOVE: if event == pycurl.POLL_REMOVE:
self.io_loop.remove_handler(fd) if fd in self._fds:
del self._fds[fd] self.io_loop.remove_handler(fd)
del self._fds[fd]
else: else:
ioloop_event = event_map[event] ioloop_event = event_map[event]
if fd not in self._fds: if fd not in self._fds:
self._fds[fd] = ioloop_event
self.io_loop.add_handler(fd, self._handle_events, self.io_loop.add_handler(fd, self._handle_events,
ioloop_event) ioloop_event)
else:
self._fds[fd] = ioloop_event self._fds[fd] = ioloop_event
else:
self.io_loop.update_handler(fd, ioloop_event) self.io_loop.update_handler(fd, ioloop_event)
self._fds[fd] = ioloop_event


def _set_timeout(self, msecs): def _set_timeout(self, msecs):
"""Called by libcurl to schedule a timeout.""" """Called by libcurl to schedule a timeout."""
Expand Down

0 comments on commit 6cf1fa1

Please sign in to comment.