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 8571905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:53:09+00:00 2026-06-11T18:53:09+00:00

# multi-processes from multiprocessing import Process, Queue class Worker(object): def __init__(self, queue): self.queue =

  • 0
# multi-processes
from multiprocessing import Process, Queue
class Worker(object):
    def __init__(self, queue):
        self.queue = queue
        self.process_num = 10 <------------ 10 processes
        self.count = 0

    def start(self):
        for i in range(self.process_num):
            p = Process(target = self.run)
            p.start()
            p.join()

    def run(self):
        while True:
            self.count += 1
            user = self.queue.get()
            # do something not so fast like time.sleep(1)
            print self.count
            if self.queue.empty():
                break

I use Worker().start(queue) to start the program, but the output is not so fast as i expected(Seems only one process are running).

Is there any problem in my code ?

  • 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-11T18:53:10+00:00Added an answer on June 11, 2026 at 6:53 pm

    Yes, you’re only running one process at a time, you’re waiting for each process to terminate before starting the next;

    def start(self):
        for i in range(self.process_num):
            p = Process(target = self.run)
            p.start()                       <-- starts a new process
            p.join()                        <-- waits for the process to terminate
    

    In other words, you’re starting 10 processes, but the second one won’t start until the first one terminates and so on.

    For what you’re trying to do, it may be better not to use Process manually and instead use a Process Pool.

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

Sidebar

Related Questions

Is putting an object in a multi-processing queue independent from getting an object from
I have a multi-process python application (processes are spawned by uwsgi) that needs to
From within a Python GUI (PyGTK) I start a process (using multiprocessing). The process
I have a design question for a multi-threaded windows service that processes messages from
I have multiple processes monitoring an MSMQ queue. I want to do multi-step operations
Possible Duplicate: Threads vs Processes in Linux To implement multi-tasks programs we could use
I'm having trouble debugging a multi-process application (specifically using a process pool in python's
Some background: My job involves maintaining a large multi-threaded multi-process C++ / C# application,
I want to know what framework/Interface/API's Set is best to use to create multi-process
I have a longer running multi-step process using BackgroundWorker and C#. I need 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.