
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Concurrent request HTTP execution library
hyper-requests is a Python library, enabling multithreading of API calls using asyncio. It takes a list of URLs and a list of parameters as input and then uses the requests library to make these calls asynchronously (https://pypi.org/project/requests/).
Install hyper-requests using pip:
pip install hyper-requests
import hyper_requests
# Define the request parameters
params = [
{'url': 'http://httpbin.org/get' , 'data': 'value1'},
{'url': 'http://httpbin.org/get' , 'data': 'value3'},
{'url': 'http://httpbin.org/get' , 'data': 'value5'},
{'url': 'http://httpbin.org/get' , 'data': 'value7'},
{'url': 'http://httpbin.org/get' , 'data': 'value9'}
]
# Create an instance of AsyncRequests and execute the requests
returned_data = hyper_requests.get(request_params=params, workers=10)
# Process the returned data
for response in returned_data:
print(response)
This example demonstrates the usage of hyper-requests to perform asynchronous HTTP(s) requests.
First, make sure you have installed hyper-requests by running the command pip install hyper-requests.
Next, import hyper_requests and utilise the .get() function.
Create a list of request parameters using dictionaries, where each dictionary represents a set of parameters for an individual request. In this example, each request MUST have a URL specified with the 'url' key, all other paramters must match the classic request template.
These must now be inputed to the .get() function, with the number of concurrent worker threads to use with the workers argument (in this case, workers=10). The return value is a list of json responses.
Finally, process the returned data as desired. In this example, each response is printed, but you can perform further operations based on your specific needs.
It is hyper fast!
Within the test/performance
directory there is a performance test that makes 20 API calls to the random joke generator api: https://official-joke-api.appspot.com/random_joke.
Using hyper requests the time taken to make these calls is ~2 second, using synchronous api calls takes ~16 seconds.
============================= test session starts ==============================
collecting ... collected 1 item
test_performance.py::PerformanceTest::test_api_performance
============================== 1 passed in 17.76s ==============================
Process finished with exit code 0
PASSED [100%]
Asynchronous Execution time: 1.845513105392456 seconds
Asynchronous Data length: 20
Synchronous Execution time: 15.81911015510559 seconds
Synchronous Data length: 20
FAQs
Concurrent request HTTP execution library
We found that hyper-requests demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.