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.

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

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.

  • 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. Commented Jan 23, 2020 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. Commented Jan 23, 2020 at 19:40
  • And since its an exit code and not an arcpy-error I cannot catch it with arcpy.ExecuteError... Commented Jan 23, 2020 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. Commented Jan 23, 2020 at 22:04
  • 1
    Might be time to contact Esri Support. Commented Jan 24, 2020 at 7:41

1 Answer 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.

  • 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? Commented Jan 23, 2020 at 19:44
  • It's base python functionality - so you can catch any errors in there. See the Python documentation: wiki.python.org/moin/HandlingExceptions
    – Kevin
    Commented Jan 23, 2020 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. Commented Jan 23, 2020 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
    Commented Jan 23, 2020 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.