__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 returnedmultiprocessing.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()