Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:35:26+00:00 2026-06-16T05:35:26+00:00

Trying the very simple following example causes my computer to grind to a halt,

  • 0

Trying the very simple following example causes my computer to grind to a halt, so that I have to restart. Checking task manager shows hundreds of “python.exe” tasks:

import math
from multiprocessing import Pool

pool = Pool(processes=2)
print pool.map(math.sqrt, [1,4,9,16])

I am using a dual core cpu (i5 2467m) so I thought the above would be fine.

I tried setting processes=1, which causes a slightly different problem: the task never completes but it does not cause my computer to freeze up.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:35:27+00:00Added an answer on June 16, 2026 at 5:35 am

    I had the same problem the first time I played around with multiprocessing. Wrap the pool generation code in a if __name__ == '__main__' block.

    import math
    from multiprocessing import Pool
    
    if __name__ == '__main__':
        pool = Pool(processes=2)
        print pool.map(math.sqrt, [1,4,9,16])
    

    What’s happening is that when the subprocess is created, your module is being unpickled and rerunning the pool generation code in an infinite recursion. With the if block, the spawning code will only run in the parent instance of the module.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to run a very simple flot.js example, I have the following code to
I have a very simple example program that I am trying to compile, but
I have a very simple Mapping I'm trying to do. I'm following the NHibernate
I am trying to make a very simple web-service which does the following: The
I am trying a very simple Fluent Nhibernate example: SQL 2005 database with one
I am trying to be super-concise, and have the following javascript code that listens
I'm trying to evaluate GWT validation library with a very simple example taken from
Given a very simple string[] , I am trying to accomplish the following in
I'm trying to set up a very simple UDP socket server with python that
I'm trying to compile a very simple program that makes a connection to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.