def _process_dict(dict_: Dict, dogpile_cache: bool = False) -> Dict[str, Any]: # Timeout after one minute, must be set to a bit less that the timeout of the broadcast timeout = time.monotonic() + 20 return { "elements": sorted( [{ "key": key, "type": _nice_type_name(value, dogpile_cache), "repr": repr(value), "id": id(value), "size_kb": get_size(value) / 1024 if time.monotonic() < timeout else -1, } for key, value in dict_.items()], key=lambda i: cast(float, -i["size_kb"]), ), "id": id(dict_), "size_kb": get_size(dict_) / 1024 if time.monotonic() < timeout else -1, "timeout": time.monotonic() > timeout, }
def _get_memory_cache(all_: bool) -> Dict[str, List[Tuple[Dict[str, Any], float]]]: values = ( [({"key": key}, get_size(value) / 1024) for key, value in list(MEMORY_CACHE_DICT.items())] if all_ else [] ) values.append(({"key": "total"}, get_size(MEMORY_CACHE_DICT) / 1024)) return {"values": values}
def _get_raster_data() -> Dict[str, List[Tuple[Dict[str, str], float]]]: return {"values": [({"key": key}, get_size(value) / 1024) for key, value in list(Raster.data.items())]}