Stack Exchange Network

Stack Exchange network consists of 182 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. Visit Stack Exchange

Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.

Sign up to join this community

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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) 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.

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-Piñeros 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. – Florian Mlehliv Jan 23, 2020 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, 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. – Marcelo Villa-Piñeros Jan 23, 2020 at 22:04

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? – Florian Mlehliv 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 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. – Florian Mlehliv Jan 23, 2020 at 21:02 It's not an exception so you can't catch it, the return code suggests that the interpreter has crashed – mikewatt Jan 23, 2020 at 21:04

Thanks for contributing an answer to Geographic Information Systems Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.