Add flags option to nanomsg port msg calls. Make port_remove non-blocking.#195
Add flags option to nanomsg port msg calls. Make port_remove non-blocking.#195fruffy wants to merge 2 commits intop4lang:mainfrom
Conversation
antoninbas
left a comment
There was a problem hiding this comment.
Doesn't that increase the probability of failure though?
If the message cannot be sent right away (maybe the peer is still consuming the previous message?), you will get an exception. It will interrupt clean up and the port won't be removed properly at the peer. Am I missing something?
Maybe you should use a thread pool instead to handle port removal in parallel.
|
True, not happy about this approach, but it seems important to make the delete call non-blocking. Interesting, did not think about a thread pool. The problem is where would that thread pool be? The messages are sent every time |
|
If you think making the call non-blocking will work well for your use case, then the less contentious and simplest option may be to add a command-line argument. You could consider reviving |
A little change to make sure clean up is somewhat non-blocking. There are some cases where cleanup can take a really long time. This is because
__del__tries to remove every single port synchronously, which gets slow for several hundred ports. Ideally, cleanup should be done in bulk by deleting all ports at once, but the current setup does not seem to support this.