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

  • SEARCH
  • Home
  • 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 7012011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:12:02+00:00 2026-05-27T22:12:02+00:00

I am new to multiprocessing I have run example code for two ‘highly recommended’

  • 0

I am new to multiprocessing

I have run example code for two ‘highly recommended’ multiprocessing examples given in response to other stackoverflow multiprocessing questions. Here is an example of one (which i dare not run again!)

test2.py (running from pydev)

import multiprocessing

class MyFancyClass(object):

    def __init__(self, name):
        self.name = name

    def do_something(self):
        proc_name = multiprocessing.current_process().name
        print(proc_name, self.name)


def worker(q):
    obj = q.get()
    obj.do_something()



queue = multiprocessing.Queue()

p = multiprocessing.Process(target=worker, args=(queue,))
p.start()

queue.put(MyFancyClass('Fancy Dan'))

# Wait for the worker to finish
queue.close()
queue.join_thread()
p.join()

When I run this my computer slows down imminently. It gets incrementally slower. After some time I managed to get into the task manager only to see MANY MANY python.exe under the processes tab. after trying to end process on some, my mouse stopped moving. It was the second time i was forced to reboot.

I am too scared to attempt a third example…

running – Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz (8 CPUs), ~2.9GHz on win7 64

If anyone know what the issue is and can provide a VERY SIMPLE example of multiprocessing (send a string too a multiprocess, alter it and send it back for printing) I would be very grateful.

  • 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-05-27T22:12:02+00:00Added an answer on May 27, 2026 at 10:12 pm

    From the docs:

    Make sure that the main module can be safely imported by a new Python
    interpreter without causing unintended side effects (such a starting a
    new process).

    Thus, on Windows, you must wrap your code inside a

    if __name__=='__main__':
    

    block.


    For example, this sends a string to the worker process, the string is reversed and the result is printed by the main process:

    import multiprocessing as mp
    
    def worker(inq,outq):
        obj = inq.get()
        obj = obj[::-1]
        outq.put(obj)
    
    if __name__=='__main__':
        inq = mp.Queue()
        outq = mp.Queue()
    
        p = mp.Process(target=worker, args=(inq,outq))
        p.start()
    
        inq.put('Fancy Dan')
    
        # Wait for the worker to finish
        p.join()
        result = outq.get()
        print(result)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

modules exists inside new processes before import, using python-multiprocessing on osx. Here's an example:
I have picked a snippet from http://docs.python.org/library/multiprocessing.html#multiprocessing-examples import multiprocessing def queue_func(queue): for i in
New day, new problem :-) Code: Client Side: void abw_Closed(object sender, EventArgs e) {
I'm new to Jython/Python world. I'm trying to install the multiprocessing package in Jython.
NEW EDIT: I have narrowed my problem to this - i have a view
I'm new to multiprocessing - and I may interpreting this wrong - but as
I'm new to Python and seems that the multiprocessing and threads module are not
new Timer().scheduleAtFixedRate(new TimerTask() { @Override public void run() { System.out.println(run); throw new SomeRandomException(); }
I have copied my home folder from a Mac OSX 10.5 to a new
new Windows 7 hides systray icons by default. what is the recommended way to

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.