Coder Social home page Coder Social logo

Comments (8)

TaiSakuma avatar TaiSakuma commented on July 18, 2024

Thank you for letting me know. I'll have a look.

from mantichora.

drhades avatar drhades commented on July 18, 2024

For reference,
defining task_loop() in another python file and importing, it'll be ok.

from mantichora.

TaiSakuma avatar TaiSakuma commented on July 18, 2024

Yes, I'm just working on this now. The code in this branch might work.

from mantichora.

TaiSakuma avatar TaiSakuma commented on July 18, 2024

I released the version 0.9.8.

It works fine in Python 3.8 on Jupyter Notebook in my environment.

Screen Shot 2020-03-14 at 11 42 00 AM

Please let me know if the problem persists.

The cause of the problem appears to be the change in the default start method in multiprocessing in Python 3.8. The default start method was "fork" until Python 3.7. But it changed to "spawn" in Python 3.8. The spawn method has more restrictions on how the main module is written as described in this section of the document for mulriprocessing. The mantichora version 0.9.8 uses the "fork" mode.

from mantichora.

drhades avatar drhades commented on July 18, 2024

@TaiSakuma
Thanks for your quick fix and detail explaination!

After upgrading to 0.9.8, the above demo code work well,
but I get the following error:
image

when using mantichora background, code like:

def task_func(*args)
    for i in atpbar(...):
        do some network things
    return something

def parallel_func()
    split something into K parts
    task_partial = partial(task_func, ...)
    with mantichora() as mcore:
        for i in range(K):
            mcore.run(task_partial, ...)
        mcore.receive_all()

It works fine by 0.9.7.

from mantichora.

TaiSakuma avatar TaiSakuma commented on July 18, 2024

Thank you for letting me know. I will look into it.

from mantichora.

TaiSakuma avatar TaiSakuma commented on July 18, 2024

I released mantichora version 0.9.9.

I added the option mp_start_method to mantichora() so that uses can choose the start method of multiprocessing. The possible values are fork, spawn, and forkserver. The default is fork. For example, if you would like to use the spawn method, which was used in mantichora v0.9.7 in Python 3.8, you can do so as

mantichora(mp_start_method='spawn')

The spawn and forkserver mothods have more restrictions, which are already mentioned above in this issue.

If you need to use the fork method, you might get the same error of may have been in progress in another thread when fork() was called. If you are getting the same error and you are on MacOS, setting the environment variable OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES might solve the problem as suggested at StackOverflow here, which you might have found already.

Please let me know if this doesn't solve the problem or causes other problems.

Thank you.

from mantichora.

TaiSakuma avatar TaiSakuma commented on July 18, 2024

I assume that the issue has been resolved. Please create a new issue if not.

from mantichora.

Related Issues (6)

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.