I'm following the cookbook tutorial on evaluating expressions. QGIS 3.16 using the in-built python editor. I've initiated the context scope in the variable context as per the tutorial. The rest is test code ultimately aiming at updating the double field Rain_D using the contents of the string field Rainfall
# Calculate Rain_D values
context = QgsExpressionContext()
context.appendScopes(QgsExpressionContextUtils.globalProjectLayerScopes(weather_l))
n = 0
with edit(weather_l):
for fea in weather_l.getFeatures():
n += 1
context.setFeature(fea)
if fea['Rainfall'].isalpha():
print(n)
weather_l.updateFeature(fea)
The problem is that when the for loop gets to about a thousand or so iterations (it's different every time) QGIS crashes. Any idea what's going on here? It works if I break after a few iterations, but not when going through the 100,000 or so records in weather_l.