Commits

Gregory Petukhov committed a661b4e

Fix bug in hammer_mode which caused incorrect timeout configuration

  • Participants
  • Parent commits f1ff390

Comments (0)

Files changed (2)

             connect_timeout, total_timeout = hammer_timeouts.pop(0)
             self.setup(connect_timeout=connect_timeout, timeout=total_timeout)
 
+
         while True:
             try:
                 self.prepare_request(**kwargs)
                 self.log_request()
                 self.transport_request()
             except GrabError, ex:
+
                 # In hammer mode try to use next timeouts
                 if self.config['hammer_mode'] and isinstance(ex, GrabTimeoutError):
                     # If not more timeouts
                         connect_timeout, total_timeout = hammer_timeouts.pop(0)
                         self.setup(connect_timeout=connect_timeout, timeout=total_timeout)
                         logger.debug('Trying another timeouts. Connect: %d sec., total: %d sec.' % (connect_timeout, total_timeout))
+                        self._request_prepared = False
                 # If we are not in hammer mode
                 # Then just raise an error
                 else:

grab/transport/curl.py

         self.curl.setopt(pycurl.MAXREDIRS, 5)
         self.curl.setopt(pycurl.CONNECTTIMEOUT, self.config['connect_timeout'])
         self.curl.setopt(pycurl.TIMEOUT, self.config['timeout'])
+
         self.curl.setopt(pycurl.NOSIGNAL, 1)
         self.curl.setopt(pycurl.WRITEFUNCTION, self.body_processor)
         self.curl.setopt(pycurl.HEADERFUNCTION, self.head_processor)