Français
Ouvrir dans Telegram
PPython Talk

Python Talk

@python_talk · groupe · Technologie · dans l'index depuis 04/07/2026
58membres
37 339messages dans l'index
O
"Friendship ended with Zig, now Rust is my best friend"
  1. A
    Browsing LinkedIn this weekend is gonna be even more painful.. "AI rewrote an entire framework from Zig to Rust. This is why coding is outdated..." 🫩
Tout le fil de discussion · 2 réponses →
G
Hey, i got a sync function that i want to call asyncronously in a loop def api_call() ... # Do api call for chunk in batched(parse_csv(local_path), BATCH_LIMIT): # Do 10 api calls in parallel using async I tried with different things but couldn't get anything working. How do you do it?
  1. C
    Don't do it. Running a synchronous function in async context breaks your loop in a way that the other concurrent functions won't run until you're done. This is likely what you have experienced when trying to make it work. Run the code in a different thread, that puts it outside of the context of the asynchronous loop. Try asyncio.to_thread and asyncio.gather.
    1. A
      I think the question is more like, I have a sync function, how do I parallel-ize it such that I can handle it like an async function without doing the threads etc. stuff myself.
      1. C
        asyncio.to_thread is the abstraction. The answer only changes if the synchronous function is developer-owned and can be converted to a native asynchronous function. Unless of course there's an option to just pick an asynchronous library (assuming the synchronous function comes from a library) to replace the synchronous function.
Tout le fil de discussion · 6 réponses →
G
can i do? with asyncio.TaskGroup() as tg: tg.create_task(asyncio.to_thread(call_api()))
  1. C
    Because the library is synchronous. If you can't replace your library with an asynchronous library, asyncio.to_thread is the answer.
Tout le fil de discussion · 2 réponses →

Un fil public ouvert issu de l'index de recherche ChatCrawler — « le Google du Telegram public » ; actualisé à mesure que la communauté est explorée. Les heures sont en UTC.

Contenu public uniquement, API officielle de Telegram. À propos · FAQ · Limites de l'index · Retirer une page · Catalogue · Recherche · Comment nous comptons