JavaScript ZeroRPC python server exceptions when attempting to stop or close zeromq python server,python zeromq server example

I have quite a bit more code than this so I'm trimming it down to just what seems to be relevant. Per the documented example, I have a python class for ZeroRPC to use:

import zerorpc, sys, signal

class MyClass:
    pass

zpc = 0
if __name == '__main__':
    zpc = zerorpc.Server(MyClass)
    zpc.bind('ipc://./mysocket.sock')
    zpc.run()
    print("zpc stopped"); sys.stdout.flush()

The python script is spawned as a ChildProcess from my Node.js server which listens to stdout and stderr. When the client connection times out, or the server shuts down, I call kill() on the ChildProcess which sends SIGTERM to it.

With just the code above, the 'zpc stopped' never gets captured at the Node.js callback which indicates to me that the ZeroRPC server gets killed somewhere in its run-loop. Also, the socket file still exists indicating the server doesn't close the socket, either. So I figured I would call stop() or close() on the server after capturing SIGTERM:

def sig_handle (signal, frame):
    global zpc
    print("SIGTERM received.") # <-- this does occur
    zpc.stop() # <-- Exception thrown here and at run()
    sys.exit(0)

signal.signal(signal.SIGTERM, sig_handle)

The exceptions are picked up by Node.js through its stderr callback:

Gateway Error:   File "/usr/lib/python2.6/site-packages/zerorpc/core.py", line 178, in stop

Gateway Error:     self._acceptor_task.kill()
  File "/usr/lib64/python2.6/site-packages/gevent/greenlet.py", line 235, in kill

Gateway Error:     waiter.get()
  File "/usr/lib64/python2.6/site-packages/gevent/hub.py", line 568, in get

Gateway Error:     return self.hub.switch()
  File "/usr/lib64/python2.6/site-packages/gevent/hub.py", line 330, in switch
    switch_out()
  File "/usr/lib64/python2.6/site-packages/gevent/hub.py", line 334, in switch_out
    raise AssertionError('Impossible to call blocking function in the event loop callback')
AssertionError: Impossible to call blocking function in the event loop callback

Gateway Error: Traceback (most recent call last):
  File "gateway.py", line 111, in <module>
    zpc.run() 

Gateway Error:   File "/usr/lib/python2.6/site-packages/zerorpc/core.py", line 171, in run
    self._acceptor_task.get()
  File "/usr/lib64/python2.6/site-packages/gevent/greenlet.py", line 258, in get

Gateway Error:     result = self.parent.switch()
  File "/usr/lib64/python2.6/site-packages/gevent/hub.py", line 331, in switch

Gateway Error:     return greenlet.switch(self)
AssertionError: Impossible to call blocking function in the event loop callback

Changing stop() to close() results in the same ultimate set of exceptions. Implementing the same idea in Javascript (Node.js), close() cleans up a running server (and its socket file in the directory) without throwing any exceptions or warnings.

This all leaves me with the question: how does one cleanly stop a ZeroRPC server in Python if not by stop() or close()?

Answer:1

Why can't you access the object property with dot notation inside a loop? var rockSpearguns = { Sharpshooter: {barbs: 2, weight: 10, heft: "overhand"}, Pokepistol: {barbs: 4, weight: 8, heft: "...

Why can't you access the object property with dot notation inside a loop? var rockSpearguns = { Sharpshooter: {barbs: 2, weight: 10, heft: "overhand"}, Pokepistol: {barbs: 4, weight: 8, heft: "...

  1. calling methods using objects in java
  2. calling methods on objects java

I'm learning AngularJS and I have a bit of a problem with directives. I don't like how they look. Specifically, I don't like when there is a lot of html in the middle of the javascript. Look at the ...

I'm learning AngularJS and I have a bit of a problem with directives. I don't like how they look. Specifically, I don't like when there is a lot of html in the middle of the javascript. Look at the ...

  1. angularjs directive without template
  2. angularjs directive without controller
  3. angularjs directive without isolated scope
  4. angularjs directive without scope
  5. angularjs directives not working
  6. angularjs directive not rendering
  7. angularjs directive not loading
  8. angularjs directive not showing
  9. angularjs directive not updating
  10. angularjs directive not being called
  11. angularjs directive not isolated scope
  12. angularjs directive not refreshing
  13. angularjs directive not updating parent scope
  14. angularjs directive not showing up
  15. angularjs directive not updating scope
  16. angularjs directive attribute without value

I'm trying to create a combobox to show moths, when I do click on january I only need to see div1 and febraury need to see div 2 like this: January........ <div> It will show info when ...

I'm trying to create a combobox to show moths, when I do click on january I only need to see div1 and febraury need to see div 2 like this: January........ <div> It will show info when ...

  1. javascript create and show div
  2. how to create a slideshow in javascript
  3. javascript createelement show
  4. create image slideshow in javascript

Everything works except for the replacement of the div. When i submit the form with jquery and ajax, my php stores the data in the database and it creates a new div that needs to be placed where the ...

Everything works except for the replacement of the div. When i submit the form with jquery and ajax, my php stores the data in the database and it creates a new div that needs to be placed where the ...

  1. with data in sql
  2. with data in r
  3. with data in excel
  4. with data of type
  5. curl with data from file
  6. with in data.table
  7. with in data.table r
  8. with in data bind
  9. curl post with data from file