httpx.ReadTimeout error each time when ads browser is closed using async Playwright
Hi! This app looks really great and this is exactly what I searched for, but I have an issue and I believe this is not an issue from my side, since the code is pretty straightforward and very close to the example in readme. Please take a look:
import asyncio
from adspower.async_api.playwright import Profile
async def main() -> None:
profile = (await Profile.query(name='acc_1'))[0]
async with profile as browser:
page = browser.pages[0]
await page.goto('https://github.com/blnkoff/adspower')
if __name__ == '__main__':
asyncio.run(main())
it throws an error:
C:\python\python311\python.exe D:\Python_Projects\test\main.py
Traceback (most recent call last):
File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 72, in map_httpcore_exceptions
yield
File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 377, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpcore\_async\connection_pool.py", line 256, in handle_async_request
raise exc from None
File "C:\python\python311\Lib\site-packages\httpcore\_async\connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpcore\_async\connection.py", line 103, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 136, in handle_async_request
raise exc
File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 106, in handle_async_request
) = await self._receive_response_headers(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 177, in _receive_response_headers
event = await self._receive_event(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 217, in _receive_event
data = await self._network_stream.read(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpcore\_backends\anyio.py", line 32, in read
with map_exceptions(exc_map):
File "C:\python\python311\Lib\contextlib.py", line 158, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\python\python311\Lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadTimeout
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Python_Projects\test\main.py", line 17, in <module>
asyncio.run(main())
File "C:\python\python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\asyncio\base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\Python_Projects\test\main.py", line 10, in main
async with profile as browser:
File "C:\python\python311\Lib\site-packages\adspower\async_api\_base_profile.py", line 13, in __aexit__
await self.quit()
File "C:\python\python311\Lib\site-packages\adspower\async_api\playwright\profile.py", line 143, in quit
await self._quit()
File "C:\python\python311\Lib\site-packages\adspower\async_api\profile_api.py", line 370, in _quit
(await client.get(**args))
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\adspower\async_api\http_client.py", line 57, in wrapper
response = await func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\adspower\async_api\http_client.py", line 33, in wrapper
result = await func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\adspower\async_api\http_client.py", line 112, in get
return await super().get(
^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1814, in get
return await self.request(
^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1585, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1674, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1702, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1739, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1776, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 376, in handle_async_request
with map_httpcore_exceptions():
File "C:\python\python311\Lib\contextlib.py", line 158, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 89, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout
Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x0000022E0D0A8900>
Traceback (most recent call last):
File "C:\python\python311\Lib\asyncio\base_subprocess.py", line 126, in __del__
File "C:\python\python311\Lib\asyncio\base_subprocess.py", line 104, in close
File "C:\python\python311\Lib\asyncio\proactor_events.py", line 109, in close
File "C:\python\python311\Lib\asyncio\base_events.py", line 762, in call_soon
File "C:\python\python311\Lib\asyncio\base_events.py", line 520, in _check_closed
RuntimeError: Event loop is closed
Process finished with exit code 1
Hi! This app looks really great and this is exactly what I searched for, but I have an issue and I believe this is not an issue from my side, since the code is pretty straightforward and very close to the example in readme. Please take a look:
import asyncio from adspower.async_api.playwright import Profile async def main() -> None: profile = (await Profile.query(name='acc_1'))[0] async with profile as browser: page = browser.pages[0] await page.goto('https://github.com/blnkoff/adspower') if __name__ == '__main__': asyncio.run(main())it throws an error:
C:\python\python311\python.exe D:\Python_Projects\test\main.py Traceback (most recent call last): File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 72, in map_httpcore_exceptions yield File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 377, in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpcore\_async\connection_pool.py", line 256, in handle_async_request raise exc from None File "C:\python\python311\Lib\site-packages\httpcore\_async\connection_pool.py", line 236, in handle_async_request response = await connection.handle_async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpcore\_async\connection.py", line 103, in handle_async_request return await self._connection.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 136, in handle_async_request raise exc File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 106, in handle_async_request ) = await self._receive_response_headers(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 177, in _receive_response_headers event = await self._receive_event(timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpcore\_async\http11.py", line 217, in _receive_event data = await self._network_stream.read( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpcore\_backends\anyio.py", line 32, in read with map_exceptions(exc_map): File "C:\python\python311\Lib\contextlib.py", line 158, in __exit__ self.gen.throw(typ, value, traceback) File "C:\python\python311\Lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions raise to_exc(exc) from exc httpcore.ReadTimeout The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:\Python_Projects\test\main.py", line 17, in <module> asyncio.run(main()) File "C:\python\python311\Lib\asyncio\runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\asyncio\runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\asyncio\base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "D:\Python_Projects\test\main.py", line 10, in main async with profile as browser: File "C:\python\python311\Lib\site-packages\adspower\async_api\_base_profile.py", line 13, in __aexit__ await self.quit() File "C:\python\python311\Lib\site-packages\adspower\async_api\playwright\profile.py", line 143, in quit await self._quit() File "C:\python\python311\Lib\site-packages\adspower\async_api\profile_api.py", line 370, in _quit (await client.get(**args)) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\adspower\async_api\http_client.py", line 57, in wrapper response = await func(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\adspower\async_api\http_client.py", line 33, in wrapper result = await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\adspower\async_api\http_client.py", line 112, in get return await super().get( ^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1814, in get return await self.request( ^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1585, in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1674, in send response = await self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1702, in _send_handling_auth response = await self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1739, in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpx\_client.py", line 1776, in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 376, in handle_async_request with map_httpcore_exceptions(): File "C:\python\python311\Lib\contextlib.py", line 158, in __exit__ self.gen.throw(typ, value, traceback) File "C:\python\python311\Lib\site-packages\httpx\_transports\default.py", line 89, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ReadTimeout Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x0000022E0D0A8900> Traceback (most recent call last): File "C:\python\python311\Lib\asyncio\base_subprocess.py", line 126, in __del__ File "C:\python\python311\Lib\asyncio\base_subprocess.py", line 104, in close File "C:\python\python311\Lib\asyncio\proactor_events.py", line 109, in close File "C:\python\python311\Lib\asyncio\base_events.py", line 762, in call_soon File "C:\python\python311\Lib\asyncio\base_events.py", line 520, in _check_closed RuntimeError: Event loop is closed Process finished with exit code 1
Hi, at the moment I have quite a bit of time to maintain and fix this library, if you want, you can try to figure out the problem and make a Pull Request.