{"id":6900,"date":"2020-12-27T09:32:10","date_gmt":"2020-12-27T04:02:10","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=6900"},"modified":"2023-12-30T16:42:37","modified_gmt":"2023-12-30T11:12:37","slug":"python-forking","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/python-forking\/","title":{"rendered":"Python Forking: Explanation and Illustration"},"content":{"rendered":"\n<p>Hello coders!! In this article, we will be learning about forking and its implementation in Python. In computer science and technology, the term fork has primarily two meanings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Cloning a process<\/li>\n\n\n\n<li>Developing independently from a legal copy of the source code <\/li>\n<\/ul>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Forking_in_Python\" >Forking in Python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Code_for_forking_in_python\" >Code for forking in python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Output\" >Output:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Explanation_of_the_code_for_Python_forking\" >Explanation of the code for Python forking:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Multiprocessing_in_Python\" >Multiprocessing in Python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#What_is_deadlock\" >What is deadlock?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Problem_with_using_Python_forking\" >Problem with using Python forking:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#How_to_resolve_this_Problem\" >How to resolve this Problem?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Forking_vs_Threading\" >Forking vs. Threading<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Debugging_a_forked_process_in_Python\" >Debugging a forked process in Python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Forking_HTTP_server_in_Python\" >Forking HTTP server in Python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Killing_a_forked_process_in_Python\" >Killing a forked process in Python:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Also_Read\" >Also, Read<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#Conclusion\" >Conclusion:<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-forking-in-python\"><span class=\"ez-toc-section\" id=\"Forking_in_Python\"><\/span>Forking in Python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>fork() function creates the copy of the process which calls it.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The  copy runs as a child process<\/li>\n\n\n\n<li>The data and code of the child process comes from the parent process<\/li>\n\n\n\n<li>The child process has a different id<\/li>\n\n\n\n<li>The child process is also independent of the parent process<\/li>\n<\/ul>\n\n\n\n<p>Depending on the return value of the fork() method one can understand which process they are in.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Positive &#8211; parent process<\/li>\n\n\n\n<li>Zero &#8211; child process<\/li>\n\n\n\n<li>Negative &#8211; error in the creation of process<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-code-for-forking-in-python\"><span class=\"ez-toc-section\" id=\"Code_for_forking_in_python\"><\/span>Code for forking in python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport os\ndef parent_child_process():\n    n = os.fork()\n    id = os.getpid()\n    if n &gt; 0:\n      print(&quot;Parent process: &quot;, id)\n    else:\n      print(&quot;Child process: &quot;,id)\n\nparent_child_process()\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-output\"><span class=\"ez-toc-section\" id=\"Output\"><\/span>Output:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" width=\"361\" height=\"96\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-140.png\" alt=\"python forking output\" class=\"wp-image-6908\" style=\"width:701px;height:186px\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-140.png 361w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-140-300x80.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-140-150x40.png 150w\" sizes=\"(max-width: 361px) 100vw, 361px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-explanation-of-the-code-for-python-forking\"><span class=\"ez-toc-section\" id=\"Explanation_of_the_code_for_Python_forking\"><\/span>Explanation of the code for Python forking:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>At first, we have imported the os module to run a portable operating system.<\/li>\n\n\n\n<li>As per the fork() method&#8217;s return value, we have classified the process as either child or parent.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-multiprocessing-in-python\"><span class=\"ez-toc-section\" id=\"Multiprocessing_in_Python\"><\/span>Multiprocessing in Python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><code><strong>multiprocessing.Pool<\/strong><\/code> &#8211; module provided by Python to run tasks parallelly  in a pool of processes.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom multiprocessing import Pool\nimport os\ndef double(i):\n    print(&quot;I'm process&quot;, getpid())\n    return i * 2\n\nwith Pool() as pool:\n    result = pool.map(double, &#x5B;2, 3, 4, 5])\n    print(result)\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" width=\"349\" height=\"137\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-144.png\" alt=\"multiprocessing in python\" class=\"wp-image-6914\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-144.png 349w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-144-300x118.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-144-150x59.png 150w\" sizes=\"(max-width: 349px) 100vw, 349px\" \/><\/figure>\n\n\n\n<p>As we can see we have executed multiple processes parallelly. However, a problem arises in multiprocessing when a deadlock is created.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-is-deadlock\"><span class=\"ez-toc-section\" id=\"What_is_deadlock\"><\/span>What is deadlock?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A deadlock is created between two or more processes when a process is waiting for another process to free a certain resource, whereas the other process is waiting for the former process to free its resource. Let&#8217;s see an illustration.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" width=\"555\" height=\"385\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-143.png\" alt=\"deadlock\" class=\"wp-image-6912\" style=\"width:356px;height:247px\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-143.png 555w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-143-300x208.png 300w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/image-143-150x104.png 150w\" sizes=\"(max-width: 555px) 100vw, 555px\" \/><\/figure><\/div>\n\n\n<p>Process1 is waiting for resource2, which is being used by Process2.<\/p>\n\n\n\n<p>Process2 is waiting for resource1, which is being used by Process1.<\/p>\n\n\n\n<p>Thus, both processes are waiting for each other, giving rise to a deadlock.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-problem-with-using-python-forking\"><span class=\"ez-toc-section\" id=\"Problem_with_using_Python_forking\"><\/span>Problem with using Python forking:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>fork() copies everything from memory, but it doesn&#8217;t copy the threads. The child process does not contain the threads running in the parent process. This can result in causing a deadlock.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-resolve-this-problem\"><span class=\"ez-toc-section\" id=\"How_to_resolve_this_Problem\"><\/span>How to resolve this Problem?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>This problem can be easily resolved by stopping the plain use of fork() method. Some of the methods for starting new processes are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&nbsp;<code>fork()&nbsp;followed by an&nbsp;execve()- <\/code><\/strong><code>In this the child process does not inherit<\/code> the module  state and starts from scratch<\/li>\n\n\n\n<li><strong>POSIX&nbsp;<kbd>fork()<\/kbd> &#8211;<\/strong> duplicates only the thread that calls fork()<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-forking-vs-threading\"><span class=\"ez-toc-section\" id=\"Forking_vs_Threading\"><\/span>Forking vs. Threading<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-forking\">Forking:<\/h3>\n\n\n\n<p>A new process is created looks exactly like the old process with the only difference of having a unique process Id and its own memory location. The child process does not inherit any file locks set by the process. Any semaphores that are open in the parent process is also open in the child process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-threading\">Threading:<\/h3>\n\n\n\n<p>A thread is a lightweight process that basically is just a CPU state with the process containing the remains (data, stack, I\/O, signals). Less overhead than \u201cforking\u201d is required because the initialization of a new system&#8217;s virtual memory space and the environment is not required. Each thread has its own unique ID, and the threads of the same process share the process instructions and the data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-debugging-a-forked-process-in-python\"><span class=\"ez-toc-section\" id=\"Debugging_a_forked_process_in_Python\"><\/span>Debugging a forked process in Python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One can use pdb on the main process and winpdb on the fork to debug a fork.pdb is the standard library for debugging winpdb is an advanced debugger available in Python that supports multiple threading and breakpoints. The software can be put to break early in the fork process, and the winpdb app can be attached once the break has been hit.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-forking-http-server-in-python\"><span class=\"ez-toc-section\" id=\"Forking_HTTP_server_in_Python\"><\/span>Forking HTTP server in Python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p id=\"h-httpserver-is-a-subclass-of-socketserver-tcpserver-multiple-threads-or-processes-are-not-used-in-this-to-handle-requests-to-add-threading-or-forking-a-new-class-can-be-created-using-the-appropriate-mix-in-form\">HTTPServer is a subclass of socketserver.TCPServer.Multiple threads or processes are not used in this to handle requests. To add threading or forking, a new class can be created using the appropriate mix-in form.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>class socketserver.ForkingMixIn<\/li>\n\n\n\n<li>class socketserver.ThreadingMixIn<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-killing-a-forked-process-in-python\"><span class=\"ez-toc-section\" id=\"Killing_a_forked_process_in_Python\"><\/span>Killing a forked process in Python:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><code><strong>os.kill()<\/strong><\/code>\u00a0is the method available in Python, which is used to send a signal to the specified process with the given process id. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport os\nimport signal\n\nmy_pid = os.getpid()\n\nos.kill(my_pid, signal.SIGINT)\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-also-read\"><span class=\"ez-toc-section\" id=\"Also_Read\"><\/span><strong>Also, Read<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"http:\/\/www.pythonpool.com\/python-swap\/\" rel=\"noreferrer noopener\" target=\"_blank\">Python Swap of two variables using Python programming<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/www.pythonpool.com\/max-heap-python\/\" rel=\"noreferrer noopener\" target=\"_blank\">Max Heap Python Implementation | Python Max Heap<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/www.pythonpool.com\/python-timer\/\" rel=\"noreferrer noopener\" target=\"_blank\">Understanding the Python Timer Class with Examples<\/a><\/li>\n\n\n\n<li><a href=\"http:\/\/www.pythonpool.com\/knapsack-problem-python\/\" rel=\"noreferrer noopener\" target=\"_blank\">Knapsack Problem in Python With Various Ways to Solve<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we learned all about forking in Python. We also learned about deadlock and saw how to resolve deadlocks while forking. Then, we moved on to learn the difference between forking and threading and saw how to <a href=\"https:\/\/en.wikipedia.org\/wiki\/Debugging\" target=\"_blank\" rel=\"noreferrer noopener\">debug<\/a> and kill a forked process in Python.<\/p>\n\n\n\n<p>However, if you have any doubts or questions, do let me know in the comment section below. I will try to help you as soon as possible.<\/p>\n\n\n\n<p><strong><em>Happy Pythoning!<\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello coders!! In this article, we will be learning about forking and its implementation in Python. In computer science and technology, the term fork has &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Python Forking: Explanation and Illustration\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/python-forking\/#more-6900\" aria-label=\"More on Python Forking: Explanation and Illustration\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":6977,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[135,15],"tags":[3013,3016,3014,3012,3018,3015,3017],"class_list":["post-6900","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-learning","category-tutorials","tag-forking-a-process-in-python","tag-forking-in-python","tag-forking-in-python-3","tag-forking-python","tag-python-forking-process","tag-python-process-forking","tag-what-is-forking-python","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Forking: Explanation and Illustration - Python Pool .<\/title>\n<meta name=\"description\" content=\"Python forking is used to create a copy of the process. Depending on the return value, the process can be parent,child or invalid\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/python-forking\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Forking: Explanation and Illustration\" \/>\n<meta property=\"og:description\" content=\"Hello coders!! In this article, we will be learning about forking and its implementation in Python. In computer science and technology, the term fork has\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/python-forking\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-27T04:02:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-30T11:12:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prachee Sao\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prachee Sao\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/\"},\"author\":{\"name\":\"Prachee Sao\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/b91d749826b21e606d55cda77d51ef47\"},\"headline\":\"Python Forking: Explanation and Illustration\",\"datePublished\":\"2020-12-27T04:02:10+00:00\",\"dateModified\":\"2023-12-30T11:12:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/\"},\"wordCount\":753,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png\",\"keywords\":[\"forking a process in python\",\"forking in python\",\"forking in python 3\",\"forking python\",\"python forking process\",\"python process forking\",\"what is forking python\"],\"articleSection\":[\"Learning\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/python-forking\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/\",\"url\":\"https:\/\/www.pythonpool.com\/python-forking\/\",\"name\":\"Python Forking: Explanation and Illustration - Python Pool .\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png\",\"datePublished\":\"2020-12-27T04:02:10+00:00\",\"dateModified\":\"2023-12-30T11:12:37+00:00\",\"description\":\"Python forking is used to create a copy of the process. Depending on the return value, the process can be parent,child or invalid\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/python-forking\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png\",\"width\":1350,\"height\":650,\"caption\":\"python forking\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/python-forking\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Forking: Explanation and Illustration\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/b91d749826b21e606d55cda77d51ef47\",\"name\":\"Prachee Sao\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d018c3758049ab2511d0772ac1f73c338aaa8c921577f39e0f1e5716fc7efcb4?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d018c3758049ab2511d0772ac1f73c338aaa8c921577f39e0f1e5716fc7efcb4?s=96&d=wavatar&r=g\",\"caption\":\"Prachee Sao\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Forking: Explanation and Illustration - Python Pool .","description":"Python forking is used to create a copy of the process. Depending on the return value, the process can be parent,child or invalid","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pythonpool.com\/python-forking\/","og_locale":"en_US","og_type":"article","og_title":"Python Forking: Explanation and Illustration","og_description":"Hello coders!! In this article, we will be learning about forking and its implementation in Python. In computer science and technology, the term fork has","og_url":"https:\/\/www.pythonpool.com\/python-forking\/","og_site_name":"Python Pool","article_published_time":"2020-12-27T04:02:10+00:00","article_modified_time":"2023-12-30T11:12:37+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png","type":"image\/png"}],"author":"Prachee Sao","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Prachee Sao","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/python-forking\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/python-forking\/"},"author":{"name":"Prachee Sao","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/b91d749826b21e606d55cda77d51ef47"},"headline":"Python Forking: Explanation and Illustration","datePublished":"2020-12-27T04:02:10+00:00","dateModified":"2023-12-30T11:12:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-forking\/"},"wordCount":753,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png","keywords":["forking a process in python","forking in python","forking in python 3","forking python","python forking process","python process forking","what is forking python"],"articleSection":["Learning","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/python-forking\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/python-forking\/","url":"https:\/\/www.pythonpool.com\/python-forking\/","name":"Python Forking: Explanation and Illustration - Python Pool .","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png","datePublished":"2020-12-27T04:02:10+00:00","dateModified":"2023-12-30T11:12:37+00:00","description":"Python forking is used to create a copy of the process. Depending on the return value, the process can be parent,child or invalid","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/python-forking\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/python-forking\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/python-forking\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/12\/Theatre-Actor-Portfolio-Website-50.png","width":1350,"height":650,"caption":"python forking"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/python-forking\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Python Forking: Explanation and Illustration"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/b91d749826b21e606d55cda77d51ef47","name":"Prachee Sao","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d018c3758049ab2511d0772ac1f73c338aaa8c921577f39e0f1e5716fc7efcb4?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d018c3758049ab2511d0772ac1f73c338aaa8c921577f39e0f1e5716fc7efcb4?s=96&d=wavatar&r=g","caption":"Prachee Sao"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6900","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=6900"}],"version-history":[{"count":13,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6900\/revisions"}],"predecessor-version":[{"id":31339,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/6900\/revisions\/31339"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/6977"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=6900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=6900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=6900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}