https://github.com/aio-libs The set of asyncio-based libraries built with high quality
popravich on travis_pypy
.travis.yml: chaching pip packa… Makefile: build/install only re… .travis.yml: cache redis-server… (compare)
Hi team, weird one. I'm using asyncio and aiohttp for a webserver using python3.8.
I'm getting continual ConnectionResetError: Cannot write to closing transport errors when I uncleanly leave the hosted page.
I see it's fixed in 3.7.2, which I'm on.
https://gist.github.com/shauneccles/eeb42b5123cfc575d80ded119a78026e
Any ideas?
Did you mean oauth2 by
oath2
mention? What library did you use for the voice assistant? Did you try to contact the library authors?
library author say ins not problem of component. oauth2 create api homeassitant
Stumbling across this issue and the PR in the comments seems to have fixed this for me
Hi all,
I have a question regarding to PR 4080 (which is "Don't cancel web handler on disconnection"; aio-libs/aiohttp#4080). I wrote a code snippet to see the difference on peer disconnection situation but on the both versions before and after the PR (which is aiohttp 3.6.3 and 3.7.3), the web handler is cancelled on peer disconnection.
Code:
import asyncio
import traceback
from aiohttp import web
async def handler(request):
print('job started')
try:
await asyncio.sleep(3)
except BaseException:
traceback.print_exc()
raise
print('job done')
return web.Response(text='hello')
app = web.Application()
app.add_routes([web.get('/', handler)])
web.run_app(app, port=7878)
Result:
======== Running on http://0.0.0.0:7878 ========
(Press CTRL+C to quit)
job started
Traceback (most recent call last):
File "main.py", line 9, in handler
await asyncio.sleep(3)
File "/home/pjknkda/.pyenv/versions/3.8.6/lib/python3.8/asyncio/tasks.py", line 656, in sleep
return await future
asyncio.exceptions.CancelledError
Client:
pjknkda@local-server:~/test/aiohttp_cancel_test$ curl http://127.0.0.1:7878
(before 3 seconds)^C
I wonder if it is the intended behavior.
Hey guys I need some help using aiohttp
I have a list of proxies to check in the format:
108.30.209.198:80
124.158.167.18:8080
195.154.207.153:80
47.244.235.213:80
192.162.193.243:36910
95.31.5.29:54651
157.230.103.189:36399
86.110.27.165:3128
113.254.178.224:8383
182.160.124.26:8081
203.176.135.102:52234
51.15.196.124:80
190.85.115.78:3128
185.61.176.176:8080
54.159.141.165:80
203.202.245.58:80
51.77.123.244:80
I need to check two things:
What type of proxy it is (http, socks4, socks5)
If it's alive
Currently, the way I'm doing it is with requests, but it's super slow. I want to move to an asynchronous checking method.
What I have now:
for proxy_type in ['http', 'socks4', 'socks5']:
try:
proxies = {
'http': f'{proxy_type}://{proxy}',
'https': f'{proxy_type}://{proxy}',
}
requests.get('https://api.ipify.org', proxies=proxies, timeout=10)
return proxies, proxy_type
except:
pass
return None, None
What I want to do:
Asynchronously do a get request using each proxy, I need there to be a thread count I can control.
Also, asynchronously recheck a proxy using all three different types of proxy protocols.
For example, if our list we're checking is the proxy list above (real list is in the hundreds of thousands) and our thread count is 3 (will most likely be something like 30 in production)
async get request using 108.30.209.198:80 proxy in http mode
async get request using 108.30.209.198:80 proxy in socks4 mode
async get request using 108.30.209.198:80 proxy in socks5 mode
Wait and gather all 3 get request results If all fail remove proxy from list, dead proxy. If one passes add proxy to good proxy list with corresponding proxy protocol
async get request using 124.158.167.18:8080 proxy in http mode
async get request using 124.158.167.18:8080 proxy in socks4 mode
async get request using 124.158.167.18:8080 proxy in socks5 mode
Wait and gather all 3 get request results If all fail remove proxy from list, dead proxy. If one passes add proxy to good proxy list with corresponding proxy protocol
async get request using 195.154.207.153:80 proxy in http mode
async get request using 195.154.207.153:80 proxy in socks4 mode
async get request using 195.154.207.153:80 proxy in socks5 mode
Wait and gather all 3 get request results If all fail remove proxy from list, dead proxy. If one passes add proxy to good proxy list with corresponding proxy protocol
What I have so far, messing around with aiohttp and aiohttp_proxy:
import asyncio
from aiohttp import ClientSession
from aiohttp_proxy import ProxyConnector, ProxyType
async def fetch(url, proxy_type, proxy):
connector = ProxyConnector.from_url(proxy_type + '://' + proxy)
try:
async with ClientSession(connector=connector) as session:
async with session.get(url, timeout=10) as response:
return await response.read(), proxy_type
except:
return None
async def run(proxy):
url = "https://api.ipify.org/"
tasks = []
for proxy_type in ['http', 'socks4', 'socks5']:
task = asyncio.ensure_future(fetch(url, proxy_type, proxy))
tasks.append(task)
responses = await asyncio.gather(*tasks)
print(responses)
loop = asyncio.get_event_loop()
future = asyncio.ensure_future(run('183.88.232.207:8080'))
loop.run_until_complete(future)