Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python
from __future__ import print_function
import gevent_openssl
gevent_openssl.monkey_patch()
import grequests
import logging
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def setup_logging():
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logging_format = '%(asctime)s %(message)s'
formatter = logging.Formatter(logging_format)
logHandler = logging.StreamHandler()
logHandler.setFormatter(formatter)
logger.addHandler(logHandler)
return logger
def make_requests(url, url_count):
pending_requests = []
for i in range(url_count):
pending_requests.append(grequests.get(url, params={'page': i}, verify=False))
all_responses = grequests.map(pending_requests)
print(all_responses)
def main():
logger = setup_logging()
logger.info('START')
make_requests('https://localhost:8082/delay/1', 10)
logger.info('END')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.