Skip to content

Commit

Permalink
Fix a bug causing redundant close() of recycled connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido van Rossum committed Mar 5, 2014
1 parent 42cabc4 commit 3a13b4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crawler/crawling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from http.client import BadStatusLine
import logging
import re
import signal
import sys
import time
import urllib.parse
Expand Down Expand Up @@ -169,7 +168,7 @@ def connect(self):
def close(self, recycle=False):
if recycle and not self.stale():
self.pool.recycle_connection(self)
elif self.writer is not None:
else:
self.writer.close()
self.pool = self.reader = self.writer = None

Expand Down Expand Up @@ -337,6 +336,7 @@ def fetch(self):
h_conn = headers.get('connection', '').lower()
if h_conn != 'close':
conn.close(recycle=True)
conn = None
if self.tries > 1:
logger.warn('try %r for %r success', self.tries, self.url)
break
Expand Down

0 comments on commit 3a13b4c

Please sign in to comment.