refactor: switch from async to sync http client
feat: bump version to 1.13.0 docs: update changelog with release notes
This commit is contained in:
parent
a2468b7d5b
commit
6509ccc5d3
@ -9,6 +9,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Version 1.12.0 - 2025-11-07
|
||||||
|
|
||||||
|
This release introduces new agent capabilities like communication, autonomous detection, and plugin support. Users can now interact with the agent in new ways and benefit from improved performance and more robust testing.
|
||||||
|
|
||||||
|
**Changes:** 4 files, 15 lines
|
||||||
|
**Languages:** Markdown (8 lines), Other (2 lines), Python (3 lines), TOML (2 lines)
|
||||||
|
|
||||||
## Version 1.11.0 - 2025-11-07
|
## Version 1.11.0 - 2025-11-07
|
||||||
|
|
||||||
This release introduces agent communication, autonomous detection, and plugin support, enabling more complex and flexible workflows. Interactive modes and a new agent execution tool have also been added, alongside performance improvements and dependency updates.
|
This release introduces agent communication, autonomous detection, and plugin support, enabling more complex and flexible workflows. Interactive modes and a new agent execution tool have also been added, alongside performance improvements and dependency updates.
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import asyncio
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
@ -10,11 +9,11 @@ from typing import Dict, Any, Optional
|
|||||||
logger = logging.getLogger("pr")
|
logger = logging.getLogger("pr")
|
||||||
|
|
||||||
|
|
||||||
class AsyncHTTPClient:
|
class SyncHTTPClient:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.session_headers = {}
|
self.session_headers = {}
|
||||||
|
|
||||||
async def request(
|
def request(
|
||||||
self,
|
self,
|
||||||
method: str,
|
method: str,
|
||||||
url: str,
|
url: str,
|
||||||
@ -23,9 +22,7 @@ class AsyncHTTPClient:
|
|||||||
json_data: Optional[Dict[str, Any]] = None,
|
json_data: Optional[Dict[str, Any]] = None,
|
||||||
timeout: float = 30.0,
|
timeout: float = 30.0,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Make an async HTTP request using urllib in a thread executor with retry logic."""
|
"""Make a sync HTTP request using urllib with retry logic."""
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
|
|
||||||
# Prepare headers
|
# Prepare headers
|
||||||
request_headers = {**self.session_headers}
|
request_headers = {**self.session_headers}
|
||||||
if headers:
|
if headers:
|
||||||
@ -46,11 +43,9 @@ class AsyncHTTPClient:
|
|||||||
while True:
|
while True:
|
||||||
attempt += 1
|
attempt += 1
|
||||||
try:
|
try:
|
||||||
# Execute in thread pool
|
# Execute request
|
||||||
response = await loop.run_in_executor(
|
with urllib.request.urlopen(req, timeout=timeout) as response:
|
||||||
None, lambda: urllib.request.urlopen(req, timeout=timeout)
|
response_data = response.read()
|
||||||
)
|
|
||||||
response_data = await loop.run_in_executor(None, response.read)
|
|
||||||
response_text = response_data.decode("utf-8")
|
response_text = response_data.decode("utf-8")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -61,7 +56,7 @@ class AsyncHTTPClient:
|
|||||||
}
|
}
|
||||||
|
|
||||||
except urllib.error.HTTPError as e:
|
except urllib.error.HTTPError as e:
|
||||||
error_body = await loop.run_in_executor(None, e.read)
|
error_body = e.read()
|
||||||
error_text = error_body.decode("utf-8")
|
error_text = error_body.decode("utf-8")
|
||||||
return {
|
return {
|
||||||
"status": e.code,
|
"status": e.code,
|
||||||
@ -86,7 +81,7 @@ class AsyncHTTPClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Exponential backoff starting at 1 second
|
# Exponential backoff starting at 1 second
|
||||||
await asyncio.sleep(attempt)
|
time.sleep(attempt)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = str(e)
|
error_msg = str(e)
|
||||||
# For other exceptions, check if they might be timeout-related
|
# For other exceptions, check if they might be timeout-related
|
||||||
@ -106,17 +101,17 @@ class AsyncHTTPClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Exponential backoff starting at 1 second
|
# Exponential backoff starting at 1 second
|
||||||
await asyncio.sleep(attempt)
|
time.sleep(attempt)
|
||||||
else:
|
else:
|
||||||
# Non-timeout errors should not be retried
|
# Non-timeout errors should not be retried
|
||||||
return {"error": True, "exception": error_msg}
|
return {"error": True, "exception": error_msg}
|
||||||
|
|
||||||
async def get(
|
def get(
|
||||||
self, url: str, headers: Optional[Dict[str, str]] = None, timeout: float = 30.0
|
self, url: str, headers: Optional[Dict[str, str]] = None, timeout: float = 30.0
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
return await self.request("GET", url, headers=headers, timeout=timeout)
|
return self.request("GET", url, headers=headers, timeout=timeout)
|
||||||
|
|
||||||
async def post(
|
def post(
|
||||||
self,
|
self,
|
||||||
url: str,
|
url: str,
|
||||||
headers: Optional[Dict[str, str]] = None,
|
headers: Optional[Dict[str, str]] = None,
|
||||||
@ -124,7 +119,7 @@ class AsyncHTTPClient:
|
|||||||
json_data: Optional[Dict[str, Any]] = None,
|
json_data: Optional[Dict[str, Any]] = None,
|
||||||
timeout: float = 30.0,
|
timeout: float = 30.0,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
return await self.request(
|
return self.request(
|
||||||
"POST", url, headers=headers, data=data, json_data=json_data, timeout=timeout
|
"POST", url, headers=headers, data=data, json_data=json_data, timeout=timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -133,4 +128,4 @@ class AsyncHTTPClient:
|
|||||||
|
|
||||||
|
|
||||||
# Global client instance
|
# Global client instance
|
||||||
http_client = AsyncHTTPClient()
|
http_client = SyncHTTPClient()
|
||||||
|
|||||||
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "rp"
|
name = "rp"
|
||||||
version = "1.11.0"
|
version = "1.12.0"
|
||||||
description = "R python edition. The ultimate autonomous AI CLI."
|
description = "R python edition. The ultimate autonomous AI CLI."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user