-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiple mad istances #43
Comments
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] |
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..). |
It looks like it is working with your fix. I have also implemented a general method:
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. |
I would like to start a certain number of madx instances (say 16) to parallelize some studies. I understand that the communication with the Madx object are blocking, although the mad process lives in a separate process. I thought to create a list of Madx object and a thread pool to send the commands, but it does not really work reliably:
The mad instances run in parallel, and partially work, however I get few of those errors:
Do you suggest another way? A process pool complains because the Madx object is not pickable.
The text was updated successfully, but these errors were encountered: