Closed omartin2010 closed 4 years ago
Fixed my own issue:
video_streamer.zmq_socket.close()
Hope this can help someone. I think this is enough to make it work well, but I've not tested extensively. Enough for my project to work.
Hi @omartin2010,
I'm glad you found the workaround. Closing the socket is exactly what is needed to allow a 2nd instantiation of imagezmq.ImageSender()
.
You have found a definite bug in imageZMQ. My own use cases and testing never needed to re-instantiate the ImageSender()
. There is, of course, a similar fault in ImageHub(). Thanks for submitting this issue.
I will fix this bug by adding the appropriate def __exit__(self, *other_stuff)
that includes zmq_socket.close()
. It will take me a few days, since I need to implement it and test it in a significant number of test programs.
In the meantime, your fix should work fine. I will leave this issue open in case someone else runs into this problem and needs your workaround.
Thanks again for finding this bug AND for providing the solution. Jeff
Hi @omartin2010 ,
I have fixed the use of imageZMQ classes in with
statements. The statement with imagezmq.ImageSender()
should work OK now. I fixed this in the most recent imageZMQ version 1.1.1.
I also added a close method in imageZMQ version 1.1.0, so that closing the zmq socket and context are done in a single method. So you can do this: video_streamer.close()
, which is more intuitive. But, when you use the with
statement, the close method is called for you, which is how the with
statement context should work.
Could you test that this newest version with your original with
statement idea? Both the GitHub version of imageZMQ and the version on PyPI are fixed now.
Thanks, Jeff
Thanks again for finding this issue. It's fixed. Let me know if you have any further problems with it.
will do - for now I'm working on another section of my project, but I will get back to the one where I use the streaming soon, and I'll update the code to use the with statement versus deleting the object. Thanks for the fix!
Great job Jeff. Love this. As I'm using this in my scenario, I may need to sometimes deallocate the streamer and reallocate it depending upon the circumstances. I get this failure:
when I run this portion of my code more than once :
Whenever it hits the 2nd line another time, I get the traceback above. Any idea how to specifically free this (I'm not myself familiar with
pyzmq
). But I would have imagined some kind of a context management :But I'm not seeing this in the source code, but if there's missing cleanup code, we would need to implement that too. Thoughts? Did I miss something? Is there an easy way to clean up sockets from this object? thanks!