extension function should release the lock on entry and reacquire it on exit when resuming python code also note that even though the python code in python threads cannot truly overlap in time due to the gil synchronizationthe -coded portions of threads can any number may be running in parallelas long as they do work outside the scope of the python virtual machine in factc threads may overlap both with other threads and with python language threads run in the virtual machine because of thissplitting code off to libraries is one way that python applications can still take advantage of multi-cpu machines stillit may often be easier to leverage such machines by simply writing python programs that fork processes instead of starting threads the complexity of process and thread code is similar for more on extensions and their threading requirementssee in shortpython includes language tools (including pair of gil management macrosthat can be used to wrap long-running operations in -coded extensions and that allow other python language threads to run in parallel process-based alternativemultiprocessing (aheadby nowyou should have basic grasp of parallel processes and threadsand python' tools that support them later in this we'll revisit both ideas to study the multiprocessing module-- standard library tool that seeks to combine the simplicity and portability of threads with the benefits of processesby implementing threadinglike api that runs processes instead of threads it seeks to address the portability issue of processesas well as the multiple-cpu limitations imposed in threads by the gilbut it cannot be used as replacement for forking in some contextsand it imposes some constraints that threads do notwhich stem from its process-based model (for instancemutable object state is not directly shared because objects are copied across process boundariesand unpickleable objects such as bound methods cannot be as freely usedbecause the multiprocessing module also implements tools to simplify tasks such as inter-process communication and exit statusthoughlet' first get handle on python' support in those domains as welland explore some more process and thread examples along the way program exits as we've seenunlike cthere is no "mainfunction in python when we run programwe simply execute all of the code in the top-level filefrom top to bottom ( in the filename we listed in the command lineclicked in file explorerand so onscripts program exits