Skip to main content

All Questions

Tagged with
1 vote
1 answer
78 views

How to "swallow" python's asyncio library's TimeoutError exception

I have a python script that connects to a server and downloads a large amount of videos and photos. And when I say large, I mean in the tens of thousands. The total amount of data to be downloaded ...
mtrojak2's user avatar
  • 123
0 votes
2 answers
52 views

My asynchronous program freezes when trying to read the html of the response

I recently started learning asyncio in python and faced a problem when I was practicing Queues. My task was to write a code that gets random pics from site, parses img links and downloads those images ...
Mushinto's user avatar
1 vote
1 answer
57 views

Using a dict for caching async function result does not use cached results

BASE_URL = "https://query2.finance.yahoo.com/" DATA_URL_PART = "v8/finance/chart/{ticker}" async def fetch_close_price(aiosession: aiohttp.ClientSession, ...
SAK's user avatar
  • 148
0 votes
1 answer
43 views

wait_for asyncio event prevents aiohttp from proper cleanup

I found unintuitive behaviour of asincio.wait_for when waiting for asyncio.Event. Aiohttp cleanup is not working in this case: import asyncio import logging from aiohttp import web async def ctx(app):...
artesby's user avatar
  • 21
1 vote
2 answers
128 views

How to use aiohttp with apscheduler?

I would like to fetch several web pages periodically all within the same aiohttp.ClientSession(). Here is what I have got so far. The URLs need to remain within the jobs, because some other URLs will ...
Serge Stroobandt's user avatar
0 votes
1 answer
57 views

Fetching multiple urls with aiohttp from a loop/generator

All examples I saw for fetching multiple urls with aiohttp suggest to to the following: async def fetch(session, url): async with session.get(url, ssl=ssl.SSLContext()) as response: return ...
dragoon's user avatar
  • 5,754
1 vote
1 answer
142 views

Closing a httpx client results in a "RuntimeError: Event loop is closed"

I need to maintain a persistent httpx client in my code to utilize its connection pool throughout the lifespan of my application. Below is a simplified version of my implementation: import asyncio ...
Babak's user avatar
  • 346
0 votes
1 answer
59 views

asyncio server does not cancels request even if aiohttp.ClientSession exceeds its timeout

The final goal is to cancel request on server side if client exceeds its timeout. The code related to start the server: def run_server_loop( routes: web.RouteTableDef, shutdown_state: ...
feeeper's user avatar
  • 3,047
1 vote
1 answer
94 views

Asyncio Proxy Checking

I am writing a script to determine working proxy servers. Everything runs smoothly with the Synchronous class, however, when I want to do this with asynchronous programming, I get very different ...
Reed Graff's user avatar
1 vote
0 answers
53 views

Asyncio.ws_connect not receiving a connection closure message

async def _connect_session(self): websocket_url, headers, cookies = self._get_connect_data() try: async with aiohttp.ClientSession(cookies=cookies) as session: logger.debug(...
Vladimir Vasiliev's user avatar
0 votes
1 answer
737 views

fastapi service throwing exception 'no running event loop'

I have a fastapi service that is using a library. The library is doing I/O. I converted the library to be full async. Changed the unit tests, and all the tests pass. Now when I try to use that library ...
feroze's user avatar
  • 7,604
2 votes
0 answers
62 views

Parallel requests gets slow when the list grows

I have created an application using FastAPI that basically exposes a POST route and execute few external requests for each incoming request. The code is really simple: from fastapi import FastAPI from ...
placplacboom's user avatar
0 votes
2 answers
83 views

When should I use await when using aiohttp?

I am new to python and I was studying asyncio/aiohttp but I'm kinda confused when should I use an "await". It's clear that I use await when I want to wait the response but let's imagine the ...
dpcllalala's user avatar
0 votes
1 answer
183 views

How to time an aiohttp request

I have an async script that looks partially like: def main(endpoints): loop = asyncio.get_event_loop() loop.run_until_complete(_main(endpoints, loop)) loop.close() async def _main(...
Mike S's user avatar
  • 1,623
0 votes
1 answer
71 views

Why are my async requests almost as slow as sync requests

My code sends async requests to an API but it's not really faster than my code with sync requests. Currently it sends around 50-60 requests and it takes around 1 minute. What am I doing wrong? #gets ...
BlackPhantom's user avatar

15 30 50 per page
1
2 3 4 5
59