grequests

Requests + Gevent = <3

https://github.com/spyoungtech/grequests

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.1%) to scientific vocabulary

Keywords from Contributors

cookies forhumans humans python-requests requests pallets werkzeug wsgi templates jinja
Last synced: 10 months ago · JSON representation

Repository

Requests + Gevent = <3

Basic Info
Statistics
  • Stars: 4,573
  • Watchers: 113
  • Forks: 331
  • Open Issues: 12
  • Releases: 4
Created about 14 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License Authors

README.rst

GRequests: Asynchronous Requests
===============================

GRequests allows you to use Requests with Gevent to make asynchronous HTTP
Requests easily.

|version| |pyversions|



Installation
------------

Installation is easy with pip::

    $ pip install grequests
    ✨🍰✨


Usage
-----

Usage is simple:

.. code-block:: python

    import grequests

    urls = [
        'http://www.heroku.com',
        'http://python-tablib.org',
        'http://httpbin.org',
        'http://python-requests.org',
        'http://fakedomain/',
        'http://kennethreitz.com'
    ]

Create a set of unsent Requests:

.. code-block:: python

    >>> rs = (grequests.get(u) for u in urls)

Send them all at the same time using ``map``:

.. code-block:: python

    >>> grequests.map(rs)
    [, , , , None, ]


The HTTP verb methods in ``grequests`` (e.g., ``grequests.get``, ``grequests.post``, etc.) accept all the same keyword arguments as in the ``requests`` library.

Error Handling
^^^^^^^^^^^^^^

To handle timeouts or any other exception during the connection of
the request, you can add an optional exception handler that will be called with the request and
exception inside the main thread. The value returned by your exception handler will be used in the result list returned by ``map``.


.. code-block:: python

    >>> def exception_handler(request, exception):
    ...    print("Request failed")

    >>> reqs = [
    ...    grequests.get('http://httpbin.org/delay/1', timeout=0.001),
    ...    grequests.get('http://fakedomain/'),
    ...    grequests.get('http://httpbin.org/status/500')]
    >>> grequests.map(reqs, exception_handler=exception_handler)
    Request failed
    Request failed
    [None, None, ]


imap
^^^^

For some speed/performance gains, you may also want to use ``imap`` instead of ``map``. ``imap`` returns a generator of responses. Order of these responses does not map to the order of the requests you send out. The API for ``imap`` is equivalent to the API for ``map``. You can also adjust the ``size`` argument to ``map`` or ``imap`` to increase the gevent pool size.


.. code-block:: python

    for resp in grequests.imap(reqs, size=10):
        print(resp)


There is also an enumerated version of ``imap``, ``imap_enumerated`` which yields the index of the request from the original request list and its associated response. However, unlike ``imap``, failed requests and exception handler results that return ``None`` will also be yielded (whereas in ``imap`` they are ignored). Aditionally, the ``requests`` parameter for ``imap_enumerated`` must be a sequence. Like in ``imap``, the order in which requests are sent and received should still be considered arbitrary.

.. code-block:: python

    >>> rs = [grequests.get(f'https://httpbin.org/status/{code}') for code in range(200, 206)]
    >>> for index, response in grequests.imap_enumerated(rs, size=5):
    ...     print(index, response)
    1 
    0 
    4 
    2 
    5 
    3 

gevent - when things go wrong
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Because ``grequests`` leverages ``gevent`` (which in turn uses monkeypatching for enabling concurrency), you will often need to make sure ``grequests`` is imported before other libraries, especially ``requests``, to avoid problems. See `grequests gevent issues `_ for additional information.


.. code-block:: python

    # GOOD
    import grequests
    import requests
    
    # BAD
    import requests
    import grequests







.. |version| image:: https://img.shields.io/pypi/v/grequests.svg?colorB=blue
    :target: https://pypi.org/project/grequests/

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/grequests.svg?
    :target: https://pypi.org/project/grequests/
    
    

Owner

  • Name: Spencer Phillip Young
  • Login: spyoungtech
  • Kind: user
  • Location: Seattle, WA
  • Company: @Bayer-Group @yesolutions

Sr. Staff Engineer. Consultant, Open Source enthusiast, Pythonista.

GitHub Events

Total
  • Issues event: 2
  • Watch event: 100
  • Pull request event: 3
  • Fork event: 3
Last Year
  • Issues event: 2
  • Watch event: 100
  • Pull request event: 3
  • Fork event: 3

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 67
  • Total Committers: 28
  • Avg Commits per committer: 2.393
  • Development Distribution Score (DDS): 0.776
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Spencer Phillip Young s****g@s****m 15
Ryan T. Dean r****d@n****m 12
Kenneth Reitz me@k****m 5
kracekumar k****r@g****m 4
Roman Haritonov r****v@g****m 3
Eugene Eeo p****8@g****m 2
Alexander Simeonov a****v@g****l 2
Adam Tauber a****o@g****m 2
Alexander Simeonov a****v@g****m 2
Michael Newman n****e@g****m 2
Chris Drackett c****s@c****m 1
Mathieu Lecarme m****e@b****m 1
Nathan Hoad n****n@g****m 1
Akshat Mahajan a****k@g****m 1
Alexandre Detiste a****e@g****m 1
Antonio A a****o@g****m 1
Chris Drackett c****s@d****m 1
Ian Cordasco i****b@c****m 1
Joe Gordon j****o@p****m 1
Karthikeyan Singaravelan t****i@g****m 1
Kenneth Reitz me@k****g 1
Luke Hutscal l****e@c****m 1
Marc Abramowitz m****c@m****m 1
Mircea Ulinic m****c 1
Nate Lawson n****e@r****g 1
Yuri Prezument y@y****m 1
koobs k****s 1
崔庆才丨静觅 c****c@c****m 1

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 92
  • Total pull requests: 25
  • Average time to close issues: over 1 year
  • Average time to close pull requests: 10 months
  • Total issue authors: 83
  • Total pull request authors: 21
  • Average comments per issue: 2.74
  • Average comments per pull request: 1.04
  • Merged pull requests: 13
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 1 day
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • latot (5)
  • spyoungtech (4)
  • ElizarovEugene (2)
  • BIGdeadLock (2)
  • guettli (1)
  • ssbarnea (1)
  • pasa13142 (1)
  • 1c7 (1)
  • small-onion (1)
  • jaytaylor (1)
  • jakehilton (1)
  • CherryQS (1)
  • deadbeef404 (1)
  • orenherman (1)
  • t-walker-wei (1)
Pull Request Authors
  • spyoungtech (5)
  • a-detiste (2)
  • 3WS85 (2)
  • somurzakov (2)
  • daniel-dong (1)
  • abruyat (1)
  • JasonnnW3000 (1)
  • venkatveeramanidaasan (1)
  • tirkarthi (1)
  • Raytlty (1)
  • Germey (1)
  • yprez (1)
  • benmcbenben (1)
  • mirceaulinic (1)
  • jogo (1)
Top Labels
Issue Labels
:hear_no_evil::see_no_evil::speak_no_evil: gevent (29) question (6) enhancement (2) invalid (2) wontfix (1)
Pull Request Labels

Packages

  • Total packages: 6
  • Total downloads:
    • pypi 412,622 last-month
  • Total docker downloads: 182,019
  • Total dependent packages: 27
    (may contain duplicates)
  • Total dependent repositories: 1,003
    (may contain duplicates)
  • Total versions: 30
  • Total maintainers: 5
pypi.org: grequests

Requests + Gevent

  • Versions: 7
  • Dependent Packages: 23
  • Dependent Repositories: 1,000
  • Downloads: 412,622 Last month
  • Docker Downloads: 182,019
Rankings
Dependent repos count: 0.4%
Downloads: 0.6%
Dependent packages count: 0.8%
Stargazers count: 1.1%
Average: 1.1%
Docker downloads count: 1.2%
Forks count: 2.8%
Maintainers (3)
Last synced: 10 months ago
alpine-edge: py3-grequests

Asynchronus HTTP requests with gevent

  • Versions: 6
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 3.4%
Average: 3.8%
Forks count: 5.7%
Dependent packages count: 6.0%
Maintainers (1)
Last synced: 11 months ago
alpine-edge: py3-grequests-pyc

Precompiled Python bytecode for py3-grequests

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 3.6%
Forks count: 5.9%
Average: 5.9%
Dependent packages count: 14.1%
Maintainers (1)
Last synced: 11 months ago
proxy.golang.org: github.com/spyoungtech/grequests
  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 11 months ago
conda-forge.org: grequests
  • Versions: 3
  • Dependent Packages: 3
  • Dependent Repositories: 3
Rankings
Stargazers count: 5.4%
Forks count: 9.2%
Average: 12.0%
Dependent packages count: 15.6%
Dependent repos count: 17.9%
Last synced: 11 months ago
spack.io: py-grequests

GRequests allows you to use Requests with Gevent to make asynchronous HTTP Requests easily. Note: You should probably use requests-threads or requests-futures instead.

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Stargazers count: 2.3%
Forks count: 5.0%
Average: 16.1%
Dependent packages count: 57.3%
Maintainers (1)
Last synced: over 1 year ago

Dependencies

requirements.txt pypi
  • gevent *
  • nose *
  • requests *
setup.py pypi
  • gevent *
  • requests *
.github/workflows/release.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • softprops/action-gh-release v1 composite
.github/workflows/test.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite