0

Using ArcPy in PyCharm, I'm constantly getting Process finished with exit code -1073741819 (0xC0000005) in my RegionGroup loop. I have posted my code in a previous question (Process finished with exit code -1073741819 (0xC0000005) from RegionGroup (ArcGIS 10.7)).
Here I want to know if there is a general possibility to catch a system exit like this (by transforming it into a "real" python error maybe), skip the current iteration and start the next.

I've looked at Catching a system exit with GDAL Python but this seemed to have been due to a GDAL-related bug.

EDIT: I've tried catching the error using try and except, but so far that has not worked.


try:
    regionGrp = RegionGroup(sinks)
    # or to avoid saving in a tmp file with potential access violations:
    region_save = "C:/.../regionGrp{}.tif".format(glacierID)
    RegionGroup(sinks).save(region_save) 
except:
    print "== strange system exit caught =="
    break

The result in the terminal (if the loop breaks) is:

Connecting regions
Compacting labels

Process finished with exit code -1073741819 (0xC0000005)

Normally it should go on like this:

Connecting regions
Compacting labels
Building Attributes
Updating link item

Maybe the error cannot be caught because it happens in the middle of this multi-step RegionGroup algorithm? I'm fairly new to python so I'm not sure if this could be a possibility.

Florian Mlehliv
  • 759
  • 5
  • 13
  • What about catching the exeception by using except SystemExit or except arcpy.ExecuteError? I cannot reproduce your error so I cannot test it but let me know if it works. – Marcelo Villa Jan 23 '20 at 17:39
  • The problem is that even I cannot always reproduce this error. Sometimes it goes through with the RegionGroup, but mostly doesn't. I've tried following your advice doing try : RegionGroup(sinks) except SystemExit: print "skip iteration" but that does not seem to have any effect. – Florian Mlehliv Jan 23 '20 at 19:40
  • And since its an exit code and not an arcpy-error I cannot catch it with arcpy.ExecuteError... – Florian Mlehliv Jan 23 '20 at 19:41
  • Does this happen only when you run the code in PyCharm? Have you tried reinstalling ArcMap? Someone suggests that it can be another program locking the memory and that restarting the computer might be a solution. – Marcelo Villa Jan 23 '20 at 22:04
  • Sadly, it also happens when I run the script via the console using the ArcGIS python. And I've upgraded my ArcGIS from 10.5 to 10.7 and restarted multiple times... I'm gonna check now if it persists on another computer with comparable installations. – Florian Mlehliv Jan 24 '20 at 07:21
  • 1
    Might be time to contact Esri Support. – Marcelo Villa Jan 24 '20 at 07:41

1 Answers1

-1

Using at Try:/Except: statement in your function should allow you to catch the exception and write out some info about what is going on.

ESRI has some good documentation on this as well.

Kevin
  • 4,926
  • 2
  • 26
  • 50
  • Thanks for the advice! I've read the documentation but they only discuss arcpy-errors in there. And my error is an exit code that seems to have to do with Windows access violations. Is there a possibility to catch those with try except? – Florian Mlehliv Jan 23 '20 at 19:44
  • It's base python functionality - so you can catch any errors in there. See the Python documentation: https://wiki.python.org/moin/HandlingExceptions – Kevin Jan 23 '20 at 20:47
  • I've updated my question with some code, as I have tried to catch it using the base python functions but it has not worked. – Florian Mlehliv Jan 23 '20 at 21:02
  • 2
    It's not an exception so you can't catch it, the return code suggests that the interpreter has crashed – mikewatt Jan 23 '20 at 21:04