New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Simulate aiohttp interface for async operations #202
Comments
I can help you implement this feature if you agree with this proposal |
In terms of requests, the AsyncSession interface is already similar enough to aiohttp that I don't think it matters |
For the asyncio interface, I trid to mimic what |
Sure, here are the features I meant: WebSocketUsing async / sync generator for receiving messages.IMO, async with session.ws_connect(ws_url) as ws: # not necessary
async for msg in ws: # exactly what I mean
# do something with msg Unfortunately, Specific datatypes wrapper methods:
async def send_str(self, data: str, compress: Optional[int] = None) -> None:
...
async def send_bytes(self, data: bytes, compress: Optional[int] = None) -> None:
...
async def send_json(
self,
data: Any,
compress: Optional[int] = None,
*,
dumps: JSONEncoder = DEFAULT_JSON_ENCODER,
) -> None:
...
async def receive_str(self, *, timeout: Optional[float] = None) -> str:
...
async def receive_bytes(self, *, timeout: Optional[float] = None) -> bytes:
...
async def receive_json(
self,
*,
loads: JSONDecoder = DEFAULT_JSON_DECODER,
timeout: Optional[float] = None,
) -> Any:
... HTTP RequestsSingle request proxy passingFor me, it seems quite convenient (at least in terms of some quick prototyping or testing) to pass a proxy to a single request as a uri: session.get("http://python.org",
proxy="http://user:pass@some.proxy.com") However, I understand, that it might not correlate well with already chosen way of handling proxies. |
All of these are valid requests, I guess. I'm happy to merge PRs if someone would be kind enough to implement them. But for the asyncio websockets, be aware that the underlying mechanism is sync-based. |
I can definitely look into implementing some of these |
Perfect, I'm glad to hear that the proposal seemed somehow useful to you |
Is your feature request related to a problem? Please describe.
aiohttp
is a widely used library, which includes connection via HTTP and WebSockets. It would be extremely helpful to have aaiohttp
-like interface for this library as it will:Describe the solution you'd like
Adapter-layer would be enough that would simulate the
aiohttp
behaviour.Describe alternatives you've considered
Write an own one is a possible solution.
However, if we have a
requests
library interface simulation, why not implement anaiohttp
interface as a standard for async version?The text was updated successfully, but these errors were encountered: