GithubHelp home page GithubHelp logo

Comments (8)

almarklein avatar almarklein commented on August 11, 2024

I'm sorry but this is not enough information to provide any help. Is it possible to create example code, that is as small as possible, but that I can run and that demonstrates the problem?

from flexx.

1751660300 avatar 1751660300 commented on August 11, 2024

ok, this is a complete example, you need
You need to package an application through the freeze method, then run, click this button.

import time
from multiprocessing import Pool
from flexx import flx

def down_single(index):
    print(f"{index}")
    time.sleep(index)

def down_multi():
    executor = Pool(2)
    for i in range(4):
        executor.apply_async(down_single, args=(i, ))
    executor.close()
    executor.join()


class Example(flx.PyWidget):

    def init(self):
        with flx.VBox():
            self.lable = flx.MultiLineEdit()
            self.button = flx.Button(text="test")
            flx.HBox(flex=1)

    @flx.reaction("button.pointer_click")
    def down_btn(self, *events):
        self.down_ac()

    @flx.action
    def down_ac(self):
        down_multi()
        self.lable.set_text("success!")

from flexx.

1751660300 avatar 1751660300 commented on August 11, 2024

After running, multiple windows will be launched and cannot be closed, as if in a computer virus, hahaha

from flexx.

almarklein avatar almarklein commented on August 11, 2024

Did you put the code to launch the app in an if __name__ == "__main__"?

if __name__ == '__main__':
    m = flx.App(Example).launch('firefox')
    flx.run()

from flexx.

1751660300 avatar 1751660300 commented on August 11, 2024

Here's the code I packed

def test_make_package_3(self):
flx.App(Example).freeze("./", excludes=[], launch="app")

from flexx.

almarklein avatar almarklein commented on August 11, 2024

Oh, I have no idea how multiprocessing works together with frozen apps. But I do know that when you "launch the pool", it spawns new processes using the same __main__ module, so if you don't guard with if __name__ == "__main__" it will re-launch the app again, and again ...

from flexx.

1751660300 avatar 1751660300 commented on August 11, 2024

yeah,i run with if name == "main", the program running ok,hope this problem can be solved later. thank you

from flexx.

1751660300 avatar 1751660300 commented on August 11, 2024

hello,
Pyinstaller packages programs that use multiprocessing must call the multiprocessing.freeze_support () method to freeze the process. I try to write the generated examp.py in the following format to solve this problem.

pyinstaller.exe "E:\code\flexx\learning\example.spec"

image

from flexx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.