Codebase list python-grequests / 0bf7e5a
Import upstream version 0.6.0 Kali Janitor 3 years ago
5 changed file(s) with 54 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
0 GRequests is written and maintained by Kenneth Reitz and
0 GRequests is authored by Kenneth Reitz, maintained by Spencer Young and
11 various contributors:
22
3 Development Lead
4 ````````````````
3 Development Leads
4 `````````````````
55
6 - Spencer Phillip Young <[email protected]>
67 - Kenneth Reitz <[email protected]>
78
89 Patches and Suggestions
910 ```````````````````````
10 - Kracekumar <[email protected]>
11 - Spencer Young <[email protected]>
11
12 Adam Tauber <[email protected]>
13 Akshat Mahajan <[email protected]>
14 Alexander Simeonov <[email protected]>
15 Antonio A <[email protected]>
16 Chris Drackett <[email protected]>
17 Eugene Eeo <[email protected]>
18 Frost Ming <[email protected]>
19 Ian Cordasco <[email protected]>
20 Joe Gordon <[email protected]>
21 Luke Hutscal <[email protected]>
22 Marc Abramowitz <[email protected]>
23 Mathieu Lecarme <[email protected]>
24 Michael Newman <[email protected]>
25 Mircea Ulinic <[email protected]>
26 Nate Lawson <[email protected]>
27 Nathan Hoad <[email protected]>
28 Roman Haritonov <[email protected]>
29 Ryan T. Dean <[email protected]>
30 Spencer Phillip Young <[email protected]>
31 Spencer Young <[email protected]>
32 Yuri Prezument <[email protected]>
33 koobs <[email protected]>
34 kracekumar <[email protected]>
35 崔庆才丨静觅 <[email protected]>
0 include LICENSE
1 include README.rst
22
33 GRequests allows you to use Requests with Gevent to make asynchronous HTTP
44 Requests easily.
5
6 |version| |pyversions|
7
58
69 **Note**: You should probably use `requests-threads <https://github.com/requests/requests-threads>`_ or `requests-futures <https://github.com/ross/requests-futures>`_ instead.
710
4447 .. code-block:: python
4548
4649 >>> def exception_handler(request, exception):
47 ... print "Request failed"
50 ... print("Request failed")
4851
4952 >>> reqs = [
5053 ... grequests.get('http://httpbin.org/delay/1', timeout=0.001),
6467
6568 $ pip install grequests
6669 ✨🍰✨
70
71
72 .. |version| image:: https://img.shields.io/pypi/v/grequests.svg?colorB=blue
73 :target: https://pypi.org/project/grequests/
74
75 .. |pyversions| image:: https://img.shields.io/pypi/pyversions/grequests.svg?
76 :target: https://pypi.org/project/grequests/
99 """
1010 from functools import partial
1111 import traceback
12
1213 try:
1314 import gevent
1415 from gevent import monkey as curious_george
2021 curious_george.patch_all(thread=False, select=False)
2122
2223 from requests import Session
23
2424
2525 __all__ = (
2626 'map', 'imap',
4646 self.session = kwargs.pop('session', None)
4747 if self.session is None:
4848 self.session = Session()
49 self._close = True
50 else:
51 self._close = False # don't close adapters after each request if the user provided the session
4952
5053 callback = kwargs.pop('callback', None)
5154 if callback:
7275 except Exception as e:
7376 self.exception = e
7477 self.traceback = traceback.format_exc()
78 finally:
79 if self._close:
80 # if we provided the session object, make sure we're cleaning up
81 # because there's no sense in keeping it open at this point if it wont be reused
82 self.session.close()
7583 return self
7684
7785
122130 ret.append(request.response)
123131 elif exception_handler and hasattr(request, 'exception'):
124132 ret.append(exception_handler(request, request.exception))
133 elif exception_handler and not hasattr(request, 'exception'):
134 ret.append(exception_handler(request, None))
125135 else:
126136 ret.append(None)
127137
3232
3333 setup(
3434 name='grequests',
35 version='0.4.0',
35 version='0.6.0',
3636 url='https://github.com/kennethreitz/grequests',
3737 license='BSD',
3838 author='Kenneth Reitz',