Coder Social home page Coder Social logo

multiple mad istances about cpymad HOT 3 OPEN

rdemaria avatar rdemaria commented on July 29, 2024
multiple mad istances

from cpymad.

Comments (3)

coldfix avatar coldfix commented on July 29, 2024

Hi, there is at leaste one error because your code doesn't ensure that at most one thread is using a particular Madx instance at a time. If two threads talk to the same Madx at the same time, it will gobble up the commands/responses and lead to crashes.

Can you try adding this guarantee, e.g.:

    def input(self,text):
        jobs = [self.pool.submit(mad.input, text) for mad in self.mad]
        return [job.result() for job in jobs]

    def input_map(self, texts):
        jobs = [self.pool.submit(mad.input, text) for mad, text in zip(self.mad, texts)]
        return [job.result() for job in jobs]

from cpymad.

coldfix avatar coldfix commented on July 29, 2024

I guess I could also investigate the possibility of adding async mode to Madx in which input() and commands return futures instead of blocking. Read access, however, would still be synchronous (because it will be significantly more work to update the entire API..).

from cpymad.

rdemaria avatar rdemaria commented on July 29, 2024

It looks like it is working with your fix. I have also implemented a general method:

    def map(self,target,*args):
        lst=zip(self.mad,zip(*args))
        jobs = [self.pool.submit(target, mad,*arg) for mad,arg in lst]
        return [job.result() for job in jobs]

However I am seeing, while on an ipython shell, a call that takes much longer than expected with the threads with 3% CPU load. It could be some i/o locking maybe, but I need to investigate further. At the moment I am using 16 mad instances in a 16 core machine.

from cpymad.

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.