This is probably a simple fix but it doesn't happen consistently so I can't figure it out.
I have a while loop that repeats if the count is less than the total. When the first loop starts, it saves the date/time. When the loop ends, I have it print both the start date/time and the end date/time. This tells the user when each loop starts and how long it took.
Here's my code:
while count < total:
bTime = datetime.datetime.now()
[do a bunch of work]
print "Repeat code for: "+str(count)+" to "+str(count+15000)
count += 15000
print "Start time: " + str(bTime)
print "End time: " + str(datetime.datetime.now())
print "Finished"
The problem is that it will run fine for awhile then suddenly error out and can't print datetime.now() because results are too large.
Repeat code for fields: 0 to 15000
Start time: 2018-03-07 10:43:46.612000
End time: 2018-03-07 12:03:59.211000
Repeat code for fields: 15000 to 30000
Start time: 2018-03-07 12:03:59.211000
End time: 2018-03-07 13:37:57.851000
...
...
Repeat code for fields: 135000 to 150000
Start time: 2018-03-08 00:44:11.488000
End time: 2018-03-08 02:22:44.780000
Repeat code for fields: 150000 to 165000
Start time: 2018-03-08 02:22:44.780000
ETraceback (most recent call last):
File "FAM_meanNDVI_extraction.py", line 210, in <module>
print "End time: " + str(datetime.datetime.now())
IOError: [Errno 34] Result too large
If anyone has an idea why it's doing this, I would greatly appreciate the help. Honestly if I just delete that line it'll work fine and I could move on with my life but it's just something nice to have for the user.