MCPcopy Create free account
hub / github.com/apify/crawlee-python / get_cpu_info

Function get_cpu_info

src/crawlee/_utils/system.py:106–114  ·  view source on GitHub ↗

Retrieve the current CPU usage. It utilizes the `psutil` library. Function `psutil.cpu_percent()` returns a float representing the current system-wide CPU utilization as a percentage.

()

Source from the content-addressed store, hash-verified

104
105
106def get_cpu_info() -> CpuInfo:
107 """Retrieve the current CPU usage.
108
109 It utilizes the `psutil` library. Function `psutil.cpu_percent()` returns a float representing the current
110 system-wide CPU utilization as a percentage.
111 """
112 logger.debug('Calling get_cpu_info()...')
113 cpu_percent = psutil.cpu_percent(interval=0.1)
114 return CpuInfo(used_ratio=cpu_percent / 100)
115
116
117def get_memory_info() -> MemoryInfo:

Calls 1

CpuInfoClass · 0.85

Tested by 1