Comments (3)
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.
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.
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)
- Differences in cpymad `table.twiss` and madx `table(twiss, X, X)` when running `use` HOT 7
- Twiss at certain positions HOT 13
- Element redefinition and twiss HOT 5
- Add support to release Linux AArch64 wheels HOT 7
- EMIT module output is displayed with "delay" HOT 2
- TWISS: no beta0 found HOT 1
- New functions
- Can't run madx instance. TypeError HOT 5
- Build error on Win10 Anaconda 2022.5 HOT 11
- What is the preferred way to retrieve the command (string) with which an Element was created? HOT 3
- libmadx error installing on M1/M2 Apple Silicon HOT 7
- Pitfalls on compiling libmadx/cpymad on Linux HOT 5
- Proposal: specialize tables HOT 8
- Wheel for M1 apple? HOT 2
- Python 3.11 Wheels HOT 4
- Error building cpymad on M1 Apple Silicon - "-march=core2" not supported HOT 5
- call does not work when double slash is present in file path HOT 2
- access default beam HOT 1
- ValueError: TypeError: write() argument must be str HOT 4
- Python 3.12 wheels HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpymad.