Closed sander76 closed 6 years ago
Threads aren't particularly expensive, but ThreadPoolExecutors will reuse threads anyway. So at a certain point, the executor won't spawn new threads but use idle ones from its pool. You can configure the pool size, look into configuring asyncio's thread pool.
Thanks ! I'll go ahead and try.
I want to write to a file many times during execution of my code.
Looking at the examples and the code a thread is created using
run_in_executor
during theopen
method ofaiofiles
. So each time I want to write to the file a new thread is created. Which is expensive I assume ? (am I now developing for a raspberrypi)Is it possible to dedicate a specific thread to a specific file ? Or should I keep the file open all the time. Do my writes and finally close it ?
Thanks !