Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 0.52 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Python Remote Procedure Call (Without the Remote Part)
  2. # Server not running as root
  3. pythonically, returned, values = other_process_running_as_root.some_method()
  4.        
  5. # Daemon running as root
  6. @expose_this_method
  7. def some_method():
  8.     # Play with RAW sockets
  9.     return pythonically, returned, values
  10.        
  11. rpcserver = zerorpc.Server("ipc://myrpc.ipc")
  12.  
  13. @rpcserver.expose
  14. def product(a, b):
  15.     return a * b
  16.  
  17. rpcserver.run()
  18.        
  19. rpcclient = zerorpc.Client("ipc://myrpc.ipc")
  20.  
  21. print(rpcclient.product(5, 7))
  22. rpcclient._stopserver()