even when threads are usedmany programmers find their scaling properties to be rather mysterious for examplea threaded network server that works fine with threads may have horrible performance if it' scaled up to , threads as general ruleyou really don' want to be writing programs with , threads because each thread requires its own system resources and the overhead associated with thread context switchinglockingand other matters starts to become significant (not to mention the fact that all threads are constrained to run on single cputo deal with thisit is somewhat common to see such applications restructured as asynchronous eventhandling systems for examplea central event loop might monitor all of the / sources using the select module and dispatch asynchronous events to large collection of / handlers this is the basis for library modules such as asyncore as well as popular third-party modules such as twisted (looking forwardmessage passing is concept that you should probably embrace for any kind of concurrent programming in python even when working with threadsan often-recommended approach is to structure your application as collection of independent threads that exchange data through message queues this particular approach tends to be less error-prone because it greatly reduces the need to use locks and other synchronization primitives message passing also naturally extends into networking and distributed systems for exampleif part of program starts out as thread to which you send messagesthat component can later be migrated to separate process or onto different machine by sending the messages over network connection the message passing abstraction is also tied to advanced python features such as coroutines for examplea coroutine is function that can receive and processe messages that are sent to it soby embracing message passingyou will find that you can write programs that have great deal of flexibility the remainder of this looks at different library modules for supporting concurrent programming at the endmore detailed information on common programming idioms is provided multiprocessing the multiprocessing module provides support for launching tasks in subprocesscommunicating and sharing dataand performing various forms of synchronization the programming interface is meant to mimic the programming interface for threads in the threading module howeverunlike threadsit is important to emphasize that processes do not have any shared state thusif process modifies datathat change is local only to that process the features of the multiprocessing module are vastmaking it one of the larger and most advanced built-in libraries covering every detail of the module is impossible herebut the essential parts of it along with examples will be given experienced programmers should be able to take the examples and expand them to larger problems processes all of the features of the multiprocessing module are focused on processes they are described by the following class lib fl ff