Deutsch
Telegram
PPython Talk

Python Talk

@python_talk · Gruppe · Technik · indexiert seit 04.07.2026
58Mitglieder
37 339Nachrichten im 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..." 🫩
Ganzer Thread · 2 Antworten →
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.
Ganzer Thread · 6 Antworten →
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.
Ganzer Thread · 2 Antworten →

Ein offener öffentlicher Feed aus dem Suchindex ChatCrawler — „Google für das öffentliche Telegram“; wird aktualisiert, während die Community gecrawlt wird. Zeiten in UTC.

Nur öffentliche Inhalte, offizielle Telegram-API. Über uns · FAQ · Grenzen des Index · Seite entfernen · Katalog · Suche · So zählen wir