privex.rpcemulator.base

Functions

quiet_serve([name, port])

Quiet version of jsonrpcserver.serve() with logging disabled.

_serve([host, port, quiet, use_coverage])

Wrapper function for jsonrpcserver.serve() and quiet_serve().

Classes

Emulator([host, port, background])

This is the base class used by JsonRPC emulators such as privex.rpcemulator.bitcoin.BitcoinEmulator

QuietRequestHandler(request, client_address, …)

Same as jsonrpcserver.server.RequestHandler but with logging disabled.

class privex.rpcemulator.base.Emulator(host='', port: int = 5000, background=True)[source]

This is the base class used by JsonRPC emulators such as privex.rpcemulator.bitcoin.BitcoinEmulator

It fires jsonrpcserver.serve() into the background using multiprocessing and handles shutting down the process either via context management (with statements), direct calls to terminate(), or when the object is garbage collected via __del__()

proc = None

Holds the multiprocessing.Process background process instance for serve()

quiet = True

Set Emulator.quiet = True to use quiet_serve() (disable HTTP request logging)

terminate()[source]

Called when a user wants to manually terminate the background process.

Simply calls __del__() to terminate the process.

use_coverage = True

When running unit tests, this should be set to True to load coverage in the subprocess

class privex.rpcemulator.base.QuietRequestHandler(request, client_address, server)[source]

Same as jsonrpcserver.server.RequestHandler but with logging disabled.

log_message(format, *args)[source]

Log an arbitrary message.

This is used by all other logging functions. Override it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it’s just like printf!).

The client ip and current date/time are prefixed to every message.

privex.rpcemulator.base.quiet_serve(name: str = '', port: int = 5000) → None[source]

Quiet version of jsonrpcserver.serve() with logging disabled.

Args:

name: Server address. port: Server port.