workhorsy / py-cpuinfo

A module for getting CPU info with pure Python
MIT License
310 stars 59 forks source link

The module not working correctly when compiling using pyinstaller or Cx_freeze #174

Closed mouadessalim closed 2 years ago

mouadessalim commented 2 years ago

So basicly i am tring to compile a simple module (py-cpuinfo) with pyinstaller or Cx_freeze with the same issue. It compile correctly but when launching the process, it create a lot of it until my cpu is full.

#testcpu.py
from cpuinfo import get_cpu_info
print(get_cpu_info())

My cpu usage after launching the program

The weird thing about it is that it's perfecty working in developement mode (python code) When launching with python When compiling i am using this parameters : pyinstaller --noconfirm --onedir --console "C:/Users/Mouad/Desktop/Payloads/cookies-grabber/testcpu.py"

Does someone know how to fix this issue ? My CPU: AMD Ryzen 5 2600X Python version: Python 3.9 I am using Windows 10 py-cpuinfo version: 8.0.0

EaxMov commented 2 years ago

NOTE: Pyinstaller may spawn infinite processes if main is not used

if name == 'main': from cpuinfo import get_cpu_info from multiprocessing import freeze_support

# NOTE: Pyinstaller also requires freeze_support
freeze_support()
info = get_cpu_info()
print(info)
mouadessalim commented 2 years ago

This is exactly what i am looking for ! Thanks.