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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:55:29+00:00 2026-05-13T15:55:29+00:00

I am writing a GUI program using PyQt4. There is a button in my

  • 0

I am writing a GUI program using PyQt4.
There is a button in my main window
and by clicking this button.
I hope to launch a background process
which is an instance of a class derived
from processing.Process.

class BackgroundTask(processing.Process):
    def __init__(self, input):
        processing.Process.__init__(self)
        ...

    def run(self):
        ...

(Note that I am using the Python2.5 port
of the python-multiprocessing obtained
from
http://code.google.com/p/python-multiprocessing/
that is why it is processing.Process
instead of multiprocessing.Process.
I guess this should not make a difference.
Am I right?)

The code connected to the button click signal
is something simply like

 processing.freezeSupport()
 task = BackgroundTask(input)
 task.start()

The program works as expected under the python intepreter, i.e.
if it is started from the command line “python myapp.py”.

However, after I package the program using py2exe,
everytime when I click that button, instead
of starting the background task, a copy
of the main window pops up. I am not sure
what is the reason of this behavior. I guess
it is related to the following note addressed
at
http://docs.python.org/library/multiprocessing.html#multiprocessing-programming

“Functionality within this package requires that the main method be importable by the children. This is covered in Programming guidelines however it is worth pointing out here. This means that some examples, such as the multiprocessing.Pool examples will not work in the interactive interpreter
“

The only place I have if name == “main” is in the main module
as in a typical pyqt program

if __name__ == "__main__":
    a = QApplication(sys.argv)
    QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
    w = MainWindow()
    w.show()
    a.exec_()

Any solutions on how to fix this problem? Thanks!

  • 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-13T15:55:29+00:00Added an answer on May 13, 2026 at 3:55 pm

    I think your actual problem has to do with this:

    The program works as expected under the python intepreter, i.e. if it is started from the command line "python myapp.py".

    However, after I package the program using py2exe, every time when I click that button, > instead of starting the background task, a copy of the main window pops up.

    You need to add a special call to the freeze_support() function to make the multiprocessing module work with "frozen" executables (eg, those made with py2exe):

    if __name__ == "__main__":
        # add freeze support
        processing.freeze_support()
        a = QApplication(sys.argv)
        QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
        w = MainWindow()
        w.show()
        a.exec_()
    

    Reference: http://docs.python.org/library/multiprocessing.html#multiprocessing.freeze_support

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

Sidebar

Ask A Question

Stats

  • Questions 352k
  • Answers 352k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Would the child() function of the XML class work for… May 14, 2026 at 7:28 am
  • Editorial Team
    Editorial Team added an answer While Nate's answer is pretty good already, I'm going to… May 14, 2026 at 7:28 am
  • Editorial Team
    Editorial Team added an answer Solved. The solution was to add <settings cacheModelsEnabled="true" /> to… May 14, 2026 at 7:28 am

Related Questions

I am writing a program in OpenGL and I need some sort of interfacing
I am writing a GUI which uses SSH commands. I tried to use the
I am just starting out with QT. I have read through some tutorials, and
I am writing an application in java (1.6) using swing. I currently have a
I'm running into a strange problem using the Toplink implementation of JPA. I'm writing

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.