Implementing a simple version of ThreadPoolExecutor in Pystd 0 ▲ Nibble Stew 1 hour ago · Tech · hide · 0 comments One of my favourite things in the Python standard library is the ThreadPoolExecutor. It is a very simple way to run a bunch of tasks in parallel, such as converting or repacking a whole bunch of image files from one format to another. You write a pure function that takes two arguments, the input and output file names, and does the conversion. Then you submit a bunch of tasks (basically function and argument pairs) and the executor runs them with maximal parallelism.I decided to implement this in Pystd. To make things simpler it does not yet support futures for return values. Writing a thread pool executor needs some fundamental building blocks such as threads, mutexes and condition variables. Once those were implemented (and working), writing the actual "business logic" turned out to be fairly simple. In fact, it took less time than writing the PNG processing code with libpng.First you need to write this helper class to register you task for running. It also stores all arguments etc… No comments yet. Log in to reply on the Fediverse. Comments will appear here.