Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Mar 21, 2024
1 parent 5dcdc51 commit 6ac5dc7
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion send_local_request_to_cogvlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import requests
from dotenv import load_dotenv
from PIL import Image
import concurrent.futures
import asyncio
import aiohttp

# Load environment variables
load_dotenv()
Expand Down Expand Up @@ -58,4 +61,34 @@ def image_to_base64(image_path):

# Print the response from the server
print(response.text)
print(f"Time taken: {time_taken} seconds")
print(f"Time taken: {time_taken} seconds")

print("Asyncio version")


# Start the timer
start_time = time.time()

async def send_request(session, url, headers, data):
async with session.post(url, headers=headers, json=data) as response:
return await response.text()

async def main():
async with aiohttp.ClientSession() as session:
tasks = []
for _ in range(30):
task = send_request(session, url, headers, request_data)
tasks.append(task)
responses = await asyncio.gather(*tasks)
for response in responses:
print(response)


# Run the main function
asyncio.run(main())

# End time
end_time = time.time()

# Print the time taken
print(f"Time taken: {end_time - start_time} seconds")

0 comments on commit 6ac5dc7

Please sign in to comment.