0
async def write_to_csv(self, asset_list, header) -> io.BytesIO:
    buffer = io.BytesIO()
    with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED, False) as zf:
        with zf.open("result.csv", "w") as f:
            writer = csv.writer(io.TextIOWrapper(f, newline="", write_through=True))
            writer.writerow(header)
            for asset in asset_list:
                writer.writerow(asset)
    buffer.seek(0)
    return buffer

I tried using the aiocsv and aiozipstream modules to make the csv and zip creation part non-blocking in the above code, which is the blocking part, but it didn't work as expected.

How can I implement the above code asynchronously?

Any help would be appriciated.

DKWoo
  • 327
  • 5
  • 17
  • 1
    Since you tried using the async versions that probably would be the suggestions for how to solve it - what didn't work as expected, what broke, and what did you expect to happen? How did you use the libraries? – MatsLindh May 04 '23 at 08:04
  • 1
    Does this answer your question? [FastAPI runs api-calls in serial instead of parallel fashion](https://stackoverflow.com/questions/71516140/fastapi-runs-api-calls-in-serial-instead-of-parallel-fashion) – Chris May 04 '23 at 09:45

0 Answers0