Skip to content
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

nzmqt and multiple instances #25

Open
machinekoder opened this issue May 23, 2014 · 2 comments
Open

nzmqt and multiple instances #25

machinekoder opened this issue May 23, 2014 · 2 comments

Comments

@machinekoder
Copy link
Collaborator

I recently came across an error when running nzmqt with multiple context screated from multiple classes. It was a segfault in the zmq lib probably caused by the multithreaded polling from more than one context (not thread-save?).

So my question is: Is there are preferred way of solving this problem with multiple classes creating multiple polling nzmqt contexts? Two possible solutions for this problem came to my mind:

  • Making PollingZMQContext a singleton
  • Using a global variable/property for managing the context

Have you already thought about that problem and what kind of solution would you prefer? I guess the singleton would be easier to implement and would keep people from mistakenly running in the problem I run into. However, the global property would probably be the more beautiful solution (and would require no changes to nzmqt)

@jonnydee
Copy link
Owner

Hi, according to http://api.zeromq.org/4-1:zmq#toc3 multiple contexts should be no problem.

So the question is: is your problem related to zmq itself or is it related to nzmqt?

In the former case I would not change anything in nzmqt as logic diverging from original zmq has drawbacks:

  • logic may not be compatible with future versions of zmq
  • people knowing the zmq world would be surprised if nzmqt behaved differently

In the latter case a fix for nzmqt is necessary, of course. However, there we need enough evidence for blaming nzmqt.

Best regards and again many thanks for your feedback!

Cheers

On May 23, 2014 8:33:39 AM CEST, strahlex [email protected] wrote:

I resently come across an error when running nzmqt with multiple
context from multiple classes. It was a segfault in the zmq lib
probably caused by the multithreaded polling from more than one context
(not thread-save?).

So my question is: Is there are prefered way of solving this problem
with multiple classes creating multiple polling nzmqt contexts? Two
possible solutions for this problem came to my mind:

  • Makung PollingZMQContext a singleton
  • Using a global variable/property for managing the context

Have you already thought about that problem and what kind of solution
would you prefer? I guess the singleton would be easier to implement
and would keep people from mistakenly running in the problem I run
into. However, the global property would probably be the more beautiful
solution (and would require no changes to nzmqt)


Reply to this email directly or view it on GitHub:
#25

@machinekoder
Copy link
Collaborator Author

Okay it turned out it was a problem with my implementation that caused the segfault.

However, how to use nzmqt with multiple ZMQContexts is probably still relevant. I think it could be more effective to use one Context instead of many (with 4 polling threads each). Maybe a ZMQSingletonPollingContext could be useful as alternative to the ZMQPollingContext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants