async def global_data_updater(): remote = Remote(SOCK_PATH) while True: try: new_data = {} data = remote.get_global() diff = await Cached.update_global(data) if diff: new_data['global'] = diff data = remote.get_torrents() diff = await Cached.update_torrents(data) if diff: new_data['torrents'] = diff plugins_data = {} for plugin in Cached.plugins: plugin_output = await plugin.get(False) if plugin_output is not None: plugins_data[plugin.name()] = plugin_output if plugins_data: new_data['plugins'] = plugins_data if len(new_data) > 0: await Cached.notify_clients(new_data) except Exception as e: logger.error(e, exc_info=e) asyncio.get_running_loop().stop() return await asyncio.sleep(RTR_RETR_INTERVAL)
def test_api_version(): sock_path = os.getenv('RTR_SCGI_SOCKET_PATH', SOCK_PATH) remote = Remote(sock_path) g = remote.get_global() assert g.system_client_version == os.getenv('RTR_SYSTEM_CLIENT_VERSION', '0.0.0') assert g.system_api_version == int(os.getenv('RTR_SYSTEM_API_VERSION', 0))