def detect_ncpus():
 global _ncpus
 if (_ncpus is None):
  if iswindows:
   import win32api
   ans = win32api.GetSystemInfo()[5]
  else:
   import multiprocessing
   ans = (-1)
   try:
    ans = multiprocessing.cpu_count()
   except Exception:
    from PyQt5.Qt import QThread
    ans = QThread.idealThreadCount()
  _ncpus = max(1, ans)
 return _ncpus

def detect_ncpus ( ) : global _ncpus if ( _ncpus is None ) : if iswindows : import win32api ans = win32api . GetSystemInfo ( ) [ 5 ] else : import multiprocessing ans = ( - 1 ) try : ans = multiprocessing . cpu_count ( ) except Exception : from PyQt5 . Qt import QThread ans = QThread . idealThreadCount ( ) _ncpus = max ( 1 , ans ) return _ncpus
detects the number of effective cpus in the system .