-
Notifications
You must be signed in to change notification settings - Fork 161
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
PUB/SUB subscriber stops working after a while #74
Comments
Using threading in your CameraHub class may be part of the problem. Quoting from the Fast Pub Sub Subscriber Helper Class docs:
You may want to try running your CameraHub loop unthreaded in the main program and see if that changes the behavior. I will leave this issue open to see if others, including @philipp-schmidt (who wrote the Fast Pub Sub Subscriber Helper Class), have any additional comments. |
I was also having the problem before adding the threaded event and, since I'm only using the one thread to receive with, I believe the threaded event should be safe but I will look into it |
What caused me to suggest it is that your |
Before I implemented the |
@johnhh2, I apologize for being slow to respond. I will try to respond more quickly going forward. I have found intermittent and sporadic blocking with imageZMQ in my own projects. I think it may be memory leaks in ZMQ, PyZMQ, Python threading, camera reading or some combination of these. While it seems to be thread related, I haven't successfully tracked these errors down yet. They may even be caused by very brief power or wifi glitches. ZMQ is a very reliable and heavily used library with great bug tracking. imageZMQ is a thin wrapper around PyZMQ. I haven't found anything specific or repeatable enough to report to ZMQ bug tracking. Like you, I use a thread to read the camera and I use another thread to send the images to an imagehub using imageZMQ. As I have been tracking down blocking and other send failures, they seem to occur more often (and are tougher to debug) when multiple threads are involved. But I don't have any repeatable examples that show threads to be the culprit. Some projects are using docker and imageZMQ without problems. One user / contributor to my own projects uses docker and has posted his own image hub-librarian here. It is a great solution and may provide you with some ideas. It is important to put every imageZMQ send in a try / except block. It is a recommended ZMQ best practice in the ZMQ docs (Quoting: In most of the C examples we’ve seen so far there’s been no error handling. Real code should do error handling on every single ZeroMQ call. ). See ZMQ docs for Handling Errors and ETERM. I have found that using timers to test for "stalls in sending or receiving" are helpful. There is an example program in this repo that shows a try / except block using ZMQ timeout options. I use imageZMQ in my yin-yang-ranch farm management project. My imagenode camera capture and sender uses imageZMQ with a separate optional "stall watcher" thread for watching for "stalls" caused by blocking on sends. I also have code that watches for stalls in my imagehub program. An overview of my workflow design for my Yin Yang Ranch system is here, in case that might be helpful to you. I have been slow to push my ongoing experiments and improvements to my GitHub repositories. No excuses for that...other than I am retired and have had a lot of life complications lately (as have we all!) Keep me posted on your progress and any solutions you come up with. My project and those of others will benefit from your learnings. Thanks, |
As the title says, I'm having issues with the subscriber no longer receiving images after a while
It randomly stops working after 6k-30k+ frames, and implementing the pub/sub 'dedicated IO' strategy did not fix the issue.
If I restart the subscriber but not the publisher it will continue receiving frames but only for about ~100 to 1k frames before it stops receiving again (stops much faster than if I were to restart both the publisher and subscriber)
Additional info:
Image size: ~45k bytes (~800x600 resolution jpgs)
Publisher and Subscriber are processing frames at 25fps
The publisher does not stop and works as expected
Subscriber code:
The text was updated successfully, but these errors were encountered: