Closed max-block closed 3 years ago
@max-block If you use AsyncHTTPProvider
, yes.
You can pass your own AsyncClient
to AsyncHTTPProvider
, like README.md
mentioned, you can control async http client manually.
tronpy use httpx as async http client, more info about HTTP Proxying of httpx, check https://www.python-httpx.org/advanced/#http-proxying
Sample code like README I think(not tested)
......
async def transfer():
_http_client = AsyncClient(limits=Limits(max_connections=100, max_keepalive_connections=20),
timeout=Timeout(timeout=10, connect=5, read=5),
proxies="http://localhost:8030")
......
Hope this helps :>
@MioYvo Thank you for the response! Yes, it's possible to use a proxy via AsyncHTTPProvider. But what's about a synchronous HTTPProvider?
Are there any reasons to use requests library for a sync mode? What do you think about using httpx for a sync mode as well? In this case it will be possible to use proxies in both modes: sync and async.
provider = HTTPProvider(....) provider.sess.proxies = {"https": "....", "http": "..."}
Yeah maybe we could replace requests with httpx, so we can use same method to deal with http
provider = HTTPProvider(....) provider.sess.proxies = {"https": "....", "http": "..."}
it works, thank you!
I thinks it's possible to solve this feature with the request_kwargs parameter.
Something like this:
What do you think about it? Do you want to add this feature, should I create a PR?