__init__

Emulator.__init__(host='', port: int = 5000, background=True)[source]

Launch an RPC emulator web server. Without arguments, will fork into background at http://127.0.0.1:5000

By default, background is set to True, meaning it will launch as a sub-process, instead of blocking your application. You can use the returned multiprocessing.Process object to terminate it once you’re done using it.

Using with a Context Manager::
>>> from privex.rpcemulator.base import Emulator
>>>
>>> with Emulator():
...     # make some queries to the RPC at https://127.0.0.1:5000
...
>>> # Once the `with` statement is over, the JsonRPC server automatically shuts down

Example:

>>> from privex.rpcemulator.base import Emulator
>>> rpc = Emulator()
>>> # make some queries to the RPC at https://127.0.0.1:5000
>>> # once you're done, terminate the process
>>> rpc.terminate()
Parameters
  • host (str) – The IP address to listen on. If left as "" - will listen at 127.0.0.1

  • port (int) – The port number to listen on (Defaults to 5000)

  • background (bool) – If True, spawns the webserver in a sub-process, instead of blocking the app.