<s> """<STR_LIT>""" <EOL> from scrapy import signals <EOL> class DownloadTimeoutMiddleware ( object ) : <EOL> def __init__ ( self , timeout = <NUM_LIT> ) : <EOL> self . _timeout = timeout <EOL> @ classmethod <EOL> def from_crawler ( cls , crawler ) : <EOL> o = cls ( crawler . settings . getfloat ( '<STR_LIT>' ) ) <EOL> crawler . signals . connect ( o . spider_opened , signal = signals . spider_opened ) <EOL> return o <EOL> def spider_opened ( self , spider ) : <EOL> self . _timeout = getattr ( spider , '<STR_LIT>' , self . _timeout ) <EOL> def process_request ( self , request , spider ) : <EOL> if self . _timeout : <EOL> request . meta . setdefault ( '<STR_LIT>' , self . _timeout ) </s>
