<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: pr-space</title>
    <description>The latest articles on DEV Community by pr-space (@pr_space).</description>
    <link>https://dev.to/pr_space</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F836722%2Fa81c3457-ea77-4035-bf54-fa50dba40ed6.png</url>
      <title>DEV Community: pr-space</title>
      <link>https://dev.to/pr_space</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pr_space"/>
    <language>en</language>
    <item>
      <title>Doubt: multiprocessing basic example</title>
      <dc:creator>pr-space</dc:creator>
      <pubDate>Fri, 25 Mar 2022 14:27:31 +0000</pubDate>
      <link>https://dev.to/pr_space/doubt-multiprocessing-basic-example-eg9</link>
      <guid>https://dev.to/pr_space/doubt-multiprocessing-basic-example-eg9</guid>
      <description>&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt; Multiprocessing basic example running in sequential order rather than parallel in jupyter notebook&lt;/p&gt;

&lt;p&gt;Question: Use multiprocessing to create three separate processes. Make each one wait a random number of seconds between one and five, print the current time, and then exit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 6) Use multiprocessing to create three separate processes. Make each one wait a random number 
# of seconds between one and five, print the current time, and then exit. 
import multiprocessing,time,datetime
import zoo

# from zoo
# def process1():
#     t1 = random.randint(1,5)
#     print("Waiting for "+str(t1)+" seconds")
#     time.sleep(t1)
#     print(datetime.datetime.now())


start = time.time()
process1 = zoo.process1()
process2 = zoo.process1()
process3 = zoo.process1()

print(datetime.datetime.now())
if __name__=="__main__":



    p1 = multiprocessing.Process(target=process1)
    p2 = multiprocessing.Process(target=process2)
    p3 = multiprocessing.Process(target=process3)

    p1.start()
    p2.start()
    p3.start()

    p1.join()
    p2.join()
    p3.join()

end = time.time()


print("It takes " +str(end-start)+" seconds")

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>help</category>
    </item>
  </channel>
</rss>
