Web appOpen in Telegram
PPython Talk

Python Talk

@python_talk · group · Tech · indexed since 2026-07-04
58members
37 339messages in the 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..." 🫩
Whole thread · 2 replies →
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.
Whole thread · 6 replies →
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.
Whole thread · 2 replies →

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count