How to benchmark a HTTP connection with requests module?

Etienne Robillard tkadm30 at yandex.com
Thu Feb 15 11:14:30 EST 2018


Hi,

Is it possible to emulate a range of concurrent connections to a http 
server with the requests module?

import os
import requests

from test_support import unittest

class HTTPBenchmarkTestCase(unittest.TestCase):

     url = 'http://localhost/benchmark/'

     def setUp(self):
         pass

     def test_benchmark_concurrency(self):
         # XXX it would be really nice to execute 10 concurrent requests
         # with 10 separated threads/connections.
         r = requests.get(self.url)
         self.assertEqual(r.status_code, 200)

     def tearDown(self):
         pass
     def runTest(self):
         pass


What do you think?

Etienne



More information about the Python-list mailing list