from xmlrpc.client import ServerProxy from time import sleep heartbeat_server_port = 10001 with ServerProxy(f'http://localhost:{heartbeat_server_port}') as proxy: # Periodically send a heartbeat while True: proxy.send_heartbeat('BATTERY') sleep(1)