def is_ssd_drive(disk_id): """Thread Safe WMI Query for checking if disk drive is SSD in MSFT_PhysicalDisk class""" if not threading.current_thread() is threading.main_thread(): pythoncom.CoInitialize() try: w = WMI(namespace='Microsoft\Windows\Storage') for m in w.MSFT_PhysicalDisk(["MediaType"], DeviceId=disk_id): return int(m.MediaType) == 4 except Exception as e: print(e) return None finally: if not threading.current_thread() is threading.main_thread(): pythoncom.CoUninitialize()