Skip to content

Commit

Permalink
Explicit setting option connection_reuse=False when proxy list is used
Browse files Browse the repository at this point in the history
  • Loading branch information
lorien committed Jul 9, 2015
1 parent 2b39c89 commit 52a0aed
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion grab/spider/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,11 @@ def process_grab_proxy(self, task, grab):

if task.use_proxylist:
if self.proxylist_enabled:
# Need this to work around
# pycurl feature/bug:
# pycurl instance uses previously connected proxy server
# even if `proxy` options is set with another proxy server
grab.setup(connection_reuse=False)
if self.proxy_auto_change:
self.proxy = self.change_proxy(task, grab)

Expand All @@ -873,7 +878,6 @@ def change_proxy(self, task, grab):
def submit_task_to_transport(self, task, grab, grab_config_backup):
self.stat.inc('spider:request-network')
self.stat.inc('spider:task-%s-network' % task.name)
self.process_grab_proxy(task, grab)
with self.timer.log_time('network_transport'):
logger_verbose.debug('Submitting task to the transport '
'layer')
Expand Down Expand Up @@ -1019,6 +1023,7 @@ def run(self):
logger.debug('Skipping network request to '
'%s' % grab.config['url'])
else:
self.process_grab_proxy(task, grab)
self.submit_task_to_transport(
task, grab, grab_config_backup)
else:
Expand Down

0 comments on commit 52a0aed

Please sign in to comment.