Loading topic
threading module. It assumes you can write Python functions and scripts and use with statements. It also assumes you know the idea of a program doing several things at once. It does not cover locks, the GIL, or pools. Those ha6 min readthreading.Thread, call start() and join(), and use with statements. It also assumes you know that threads in one process share memory. Here you will see what goes wrong when threads change the same data, and how locks and queues prevent it.6 min readthreading, you know what a race condition is, and you have seen why counter += 1 needs a lock. It builds on the earlier chapters on threads and locks. It does not cover how the GIL affects speed. The next chapter covers that.7 min readthreading or ThreadPoolExecutor. It also assumes you know the Global Interpreter Lock (GIL) lets only one thread run Python bytecode at a time, and that you can tell I/O-bound work from CPU-bound work. Here we connect those ideas: what the GIL does6 min readwith statements. It also assumes you know why CPU-bound threads are limited by the GIL, as covered in the previous chapter. Here you will learn how a separate process avoids that limit and what it costs.6 min readwith statements. It also assumes you have seen ThreadPoolExecutor and ProcessPoolExecutor and know what the GIL is. The earlier chapters explained how each tool works. This one covers how to pick one for a workload and how to check th7 min readmultiprocessing.Process and use ProcessPoolExecutor, and that you know processes have separate memory. It explains how a new worker process gets created, why that choice changes your program's behavior, and why many multiprocessing scripts need `if _name_ =5 min readmultiprocessing.Process, know why the if __name__ == "__main__": guard matters, and understand that each process has its own memory. If those are unfamiliar, review the chapters on processes and start methods first.7 min readdef functions, context managers, and Python 3.11 or later. TaskGroup and `asyncio.tim5 min readThreadPoolExecutor. The earlier chapters on the GIL and its effect on threads cover both. Here you will see why tha6 min read