Go to Project panel and exclude folders from update indexing.

Go to Project panel and exclude folders from update indexing.
Other option
file:///C:/Users/USER/Desktop/OfflineMaps/Cyprus/{z}/{x}/{y}.png
url = 'type=xyz&url=file:///C:/Users/USER/Desktop/OfflineMaps/Cyprus/%7Bz%7D/%7Bx%7D/%7By%7D.png&zmax=10&zmin=0'
layer = QgsRasterLayer(url, "CyprusOffline_python", 'wms')
QgsProject.instance().addMapLayer(layer)