-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
KeyError -1 #35
Comments
That's an interesting one. Are you using multithreading or multiprocessing to make the pyads calls? |
I've done some research based on this issue you linked Beckhoff/ADS#20 and I believe you may be the victim of spurious failure of the c++ std::atomic::compare_exchange_weak method as part of the following block which is checking to avoid a race between requests. It's only meant to happen very occasionally, however given that you're making 16,000 calls so quickly I guess it's not surprising you're running into it. if (!queue[port - Router::PORT_BASE].invokeId.compare_exchange_weak(isFree, id)) {
LOG_WARN("Port: " << port << " already in use as " << isFree);
return nullptr;
} There's a good stackoverflow question on it here if you're interested, but I believe the solution may be to swap that out with compare_exchange_strong which isn't prone to the same failure mode. I can update this on my branch of the ADS lib https://github.com/dabrowne/ADS. When I've done so could you install adslib from that repo and see if you get the same issue? |
@lexe Ok so I've made the update. Try the following and then run your code again.
|
Hi, Thanks for you solution, I think it's safe to say all is working well now since i've not encountered new errors for at least 10 minutes (40000+ calls). Thanks again for you quick solution to this. Regards, Alexander |
Great to hear it seems to be fixed. Thanks for the thorough bug report. Keep us updated if anything changes. I'll try and get this change propagated up to the Beckhoff/ADS master. Stefan will need to update the pyads submodule link to my repo for the change to be included in the next pyads release. @MrLeeH |
Dear,
First of all thanks for this library, it has been very useful.
In a (fast) cyclic program I occasionally get KeyError -1 exceptions when reading or writing data.
I get these messages when running the application in a console when the exceptions occur.
2017-09-27T21:44:38+0200 Warning: Port: 30001 already in use as 0
This is the only reference I found on the web describing the same error:
Beckhoff/ADS#20
Any idea how this can be solved?
Thanks in advance,
Alexander
The text was updated successfully, but these errors were encountered: