Skip to content
Myr

Merge branch '239-socket-leak' of https://github.com/acdha/requests into develop

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 4516bd4, 67f50a0 · Browse files · 2 files+10 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−15 removed

  • other:+10 added−15 removed

2 files+10 added−15 removed

modified:requests/async.py+5 added-8 removed
44 unmodified lines
4546 return wrapped474849def send(r, pool=None):50 """Sends the request object using the specified pool. If a pool isn't 49def send(r, pool=None, prefetch=False):50 """Sends the request object using the specified pool. If a pool isn't51 specified this method blocks. Pools are useful because you can specify size52 and can hence limit concurrency."""5354 if pool != None:55 return pool.spawn(r.send)55 return pool.spawn(r.send, prefetch=prefetch)5657 return gevent.spawn(r.send)57 return gevent.spawn(r.send, prefetch=prefetch)585960# Patched requests.api functions.61get = patched(api.get)
16 unmodified lines
7879 requests = list(requests)8081 pool = Pool(size) if size else None82 jobs = [send(r, pool) for r in requests]82 jobs = [send(r, pool, prefetch=prefetch) for r in requests]83 gevent.joinall(jobs)8485 if prefetch:86 [r.response.content for r in requests]8785 return [r.response for r in requests]
modified:requests/models.py+5 added-7 removed
201 unmodified lines
202203 history = []204205 r = build(resp)206 cookies = self.cookies206207 self.cookies.update(r.cookies)208209 if r.status_code in REDIRECT_STATI and not self.redirect:210 while (('location' in r.headers) and211 ((r.status_code is codes.see_other) or (self.allow_redirects))):212211 while (212 ('location' in r.headers) and213 ((r.status_code is codes.see_other) or (self.allow_redirects))214 ):213 r.content # Consume socket so it can be released214215 if not len(history) < self.config.get('max_redirects'):216 raise TooManyRedirects()217
33 unmodified lines
251 files=self.files,252 method=method,253 params=self.session.params,254 auth=self.auth,256 cookies=cookies,255 cookies=self.cookies,256 redirect=True,257 config=self.config,258 timeout=self.timeout,259 _poolmanager=self._poolmanager,
2 unmodified lines
262 session = self.session263 )264265 request.send()267 cookies.update(request.response.cookies)266 r = request.response267 self.cookies.update(r.cookies)268269 r.history = history
536 unmodified lines