ArcGIS Pro has stopped working when using CutFill tool

488
0
11-14-2017 02:37 AM
NghiepNeoLab
New Contributor

Hello guys

I need your help about Python of ArcGIS run on Apache. It is important for me because I much resolve it soon.

I am running Arcpy on Apache 2.4.23 within mod_wsgi but ArcGIS has the problem when execute CutFill.

The following is  Apache configuration:

WSGIPythonPath "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3"
WSGIScriptAlias / "C:\Workspace\Arcpy\apache-env\adapter.wsgi"

<Directory "C:/Workspace/Arcpy/apache-env/">
      WSGIApplicationGroup %{GLOBAL}
      Order deny,allow
      Allow from all
      Require all granted
</Directory>

And adapter.wsgi content is 

# coding: utf-8
import sys, os
sys.path.insert(0, "C:/Workspace/Arcpy/apache-env")
import bottle
import index

dirpath = os.path.dirname(os.path.abspath(__file__))
sys.path.append(dirpath)
os.chdir(dirpath)
application = bottle.default_app()

I have written Python code in index.py file like

import os, sys
import bottle, arcpy, uuid
from arcpy.sa import CutFill

from gevent import monkey; monkey.patch_all()
from bottle import get

sys.path.append(os.path.dirname(os.path.abspath(__file__)))
app = bottle.default_app()

@get(path='/cutfill', method="GET")
def cutfill():
    # set overwriteOutput
    arcpy.env.overwriteOutput = True

    # init data files
    in_before_surface = 'C:\\Workspace\\Arcpy\\apache-env\\cutfill\\a5027708f8.tif'
    in_after_surface = 'C:\\Workspace\\Arcpy\\apache-env\\cutfill\\2c963f75b3'
    z_factor = 1

    try:
        # Check out the ArcGIS Spatial Analyst extension license
        arcpy.CheckOutExtension("Spatial")

        # Execute CutFill
        outCutFill = CutFill(in_before_surface, in_after_surface, z_factor)

        # Save the output
        temporary_cut_fill = arcpy.env.workspace + "\\" + str(uuid.uuid4().hex) + ".tif"
        outCutFill.save(temporary_cut_fill)

        # get Cut and Fill values
        cut = 0
        fill = 0
        result = {}
        rows = arcpy.SearchCursor(temporary_cut_fill, ["Volume", "Area"])
        for row in rows:
            val = row.getValue("VOLUME")
            if val > 0:
                cut = cut + val
            else:
                fill = fill + val

        # Assign the value into variable
        result['Cut'] = cut
        result['Fill'] = fill
        result['Volume'] = cut + fill

        return result
     except Exception as error:
        print("{}".format(str(error)))
        return {'error': str(error)}

# Default route for GET
@get(path='/', method='GET')
def default_route():
     return "Homepage (8080)"

if __name__ == '__main__':
# prepare Arcpy environments
    cur_dir_path = os.path.dirname(os.path.realpath(__file__))
    app.config.load_config(cur_dir_path + "\\app.conf")

    try:
        # Arcpy can overwrite output
        arcpy.env.overwriteOutput = True

        # set workspace dir
        arcpy.env.workspace = app.config['app.output_path']

        # initiation for volume calculation
        arcpy.CheckOutExtension("3D")
        arcpy.CheckOutExtension("spatial")

    except Exception as error:
        print("error: {}".format(str(error)))

    app.run(host='0.0.0.0', server="gevent", port=8080, reloader=True , debug=True)

The next, I start Apache by command: C:\Apache24\bin\httpd.exe

To check what I did, I open browser/Postman 
- If I access homepage (http://localhost:8080) => It works.
- If I access http://localhost:8080/cutfill. It runs in few seconds and ArcGIS displays the pop-up and be stopped. 
Here is the pop-up 

I check Apache log and have seen
[Mon Nov 13 18:55:37.646186 2017] [mpm_winnt:notice] [pid 43960:tid 532] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.5.20 Python/3.4 configured -- resuming normal operations
[Mon Nov 13 18:55:37.646186 2017] [mpm_winnt:notice] [pid 43960:tid 532] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Mon Nov 13 18:55:37.646186 2017] [core:notice] [pid 43960:tid 532] AH00094: Command line: 'httpd.exe -d C:/Apache24'
[Mon Nov 13 18:55:37.646186 2017] [core:debug] [pid 43960:tid 532] log.c(1543): AH02639: Using SO_REUSEPORT: no (0)
[Mon Nov 13 18:55:37.647164 2017] [mpm_winnt:notice] [pid 43960:tid 532] AH00418: Parent: Created child process 112032
[Mon Nov 13 18:55:37.647164 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(429): AH00402: Parent: Sent the scoreboard to the child
[Mon Nov 13 18:55:37.865186 2017] [mpm_winnt:debug] [pid 112032:tid 516] mpm_winnt.c(1718): AH00453: Child process is running
[Mon Nov 13 18:55:37.865186 2017] [wsgi:info] [pid 112032:tid 516] mod_wsgi (pid=112032): Initializing Python.
[Mon Nov 13 18:55:37.921188 2017] [wsgi:info] [pid 112032:tid 516] mod_wsgi (pid=112032): Attach interpreter ''.
[Mon Nov 13 18:55:37.923189 2017] [wsgi:info] [pid 112032:tid 516] mod_wsgi (pid=112032): Adding 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3' to path.
[Mon Nov 13 18:55:37.926189 2017] [mpm_winnt:debug] [pid 112032:tid 516] mpm_winnt.c(343): AH00391: Child: Retrieved our scoreboard from the parent.
[Mon Nov 13 18:55:37.926189 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 504 (0.0.0.0:8080) and sending it to child process 112032
[Mon Nov 13 18:55:37.926189 2017] [mpm_winnt:debug] [pid 112032:tid 516] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket 0.0.0.0:8080
[Mon Nov 13 18:55:37.927189 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 508 ([::]:8080) and sending it to child process 112032
[Mon Nov 13 18:55:37.927189 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(531): AH00411: Parent: Sent 2 listeners to child 112032
[Mon Nov 13 18:55:37.927189 2017] [mpm_winnt:debug] [pid 112032:tid 516] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket [::]:8080
[Mon Nov 13 18:55:37.927189 2017] [mpm_winnt:debug] [pid 112032:tid 516] mpm_winnt.c(490): AH00407: Child: retrieved 2 listeners from parent
[Mon Nov 13 18:55:37.927189 2017] [mpm_winnt:debug] [pid 112032:tid 516] child.c(1020): AH00352: Child: Acquired the start mutex.
[Mon Nov 13 18:55:37.927189 2017] [mpm_winnt:notice] [pid 112032:tid 516] AH00354: Child: Starting 64 worker threads.
[Mon Nov 13 18:55:37.929151 2017] [mpm_winnt:debug] [pid 112032:tid 1164] child.c(399): AH00334: Child: Accept thread listening on 0.0.0.0:8080 using AcceptFilter data
[Mon Nov 13 18:55:37.929151 2017] [mpm_winnt:debug] [pid 112032:tid 1172] child.c(399): AH00334: Child: Accept thread listening on [::]:8080 using AcceptFilter data
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[Mon Nov 13 18:56:06.092403 2017] [authz_core:debug] [pid 112032:tid 1180] mod_authz_core.c(806): [client ::1:52362] AH01626: authorization result of Require all granted: granted
[Mon Nov 13 18:56:06.092403 2017] [authz_core:debug] [pid 112032:tid 1180] mod_authz_core.c(806): [client ::1:52362] AH01626: authorization result of <RequireAny>: granted
[Mon Nov 13 18:56:06.092403 2017] [authz_core:debug] [pid 112032:tid 1180] mod_authz_core.c(806): [client ::1:52362] AH01626: authorization result of Require all granted: granted
[Mon Nov 13 18:56:06.092403 2017] [authz_core:debug] [pid 112032:tid 1180] mod_authz_core.c(806): [client ::1:52362] AH01626: authorization result of <RequireAny>: granted
[Mon Nov 13 18:56:06.093403 2017] [wsgi:info] [pid 112032:tid 1180] [client ::1:52362] mod_wsgi (pid=112032, process='', application=''): Loading WSGI script 'C:/Workspace/Arcpy/apache-env/adapter.wsgi'.
[Mon Nov 13 18:56:19.479013 2017] [mpm_winnt:notice] [pid 43960:tid 532] AH00428: Parent: child process 112032 exited with status 4294967295 -- Restarting.
[Mon Nov 13 18:56:19.501013 2017] [mpm_winnt:notice] [pid 43960:tid 532] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.5.20 Python/3.4 configured -- resuming normal operations
[Mon Nov 13 18:56:19.501013 2017] [mpm_winnt:notice] [pid 43960:tid 532] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Mon Nov 13 18:56:19.501013 2017] [core:notice] [pid 43960:tid 532] AH00094: Command line: 'httpd.exe -d C:/Apache24'
[Mon Nov 13 18:56:19.501013 2017] [core:debug] [pid 43960:tid 532] log.c(1543): AH02639: Using SO_REUSEPORT: no (0)
[Mon Nov 13 18:56:19.502013 2017] [mpm_winnt:notice] [pid 43960:tid 532] AH00418: Parent: Created child process 45568
[Mon Nov 13 18:56:19.502013 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(429): AH00402: Parent: Sent the scoreboard to the child
[Mon Nov 13 18:56:19.799012 2017] [mpm_winnt:debug] [pid 45568:tid 520] mpm_winnt.c(1718): AH00453: Child process is running
[Mon Nov 13 18:56:19.800013 2017] [wsgi:info] [pid 45568:tid 520] mod_wsgi (pid=45568): Initializing Python.
[Mon Nov 13 18:56:19.852012 2017] [wsgi:info] [pid 45568:tid 520] mod_wsgi (pid=45568): Attach interpreter ''.
[Mon Nov 13 18:56:19.853012 2017] [wsgi:info] [pid 45568:tid 520] mod_wsgi (pid=45568): Adding 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3' to path.
[Mon Nov 13 18:56:19.856012 2017] [mpm_winnt:debug] [pid 45568:tid 520] mpm_winnt.c(343): AH00391: Child: Retrieved our scoreboard from the parent.
[Mon Nov 13 18:56:19.856012 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 508 ([::]:8080) and sending it to child process 45568
[Mon Nov 13 18:56:19.857012 2017] [mpm_winnt:debug] [pid 45568:tid 520] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket 0.0.0.0:8080
[Mon Nov 13 18:56:19.857012 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 504 (0.0.0.0:8080) and sending it to child process 45568
[Mon Nov 13 18:56:19.857012 2017] [mpm_winnt:debug] [pid 43960:tid 532] mpm_winnt.c(531): AH00411: Parent: Sent 2 listeners to child 45568
[Mon Nov 13 18:56:19.857012 2017] [mpm_winnt:debug] [pid 45568:tid 520] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket [::]:8080
[Mon Nov 13 18:56:19.857012 2017] [mpm_winnt:debug] [pid 45568:tid 520] mpm_winnt.c(490): AH00407: Child: retrieved 2 listeners from parent
[Mon Nov 13 18:56:19.857012 2017] [mpm_winnt:debug] [pid 45568:tid 520] child.c(1020): AH00352: Child: Acquired the start mutex.
[Mon Nov 13 18:56:19.857012 2017] [mpm_winnt:notice] [pid 45568:tid 520] AH00354: Child: Starting 64 worker threads.
[Mon Nov 13 18:56:19.859012 2017] [mpm_winnt:debug] [pid 45568:tid 1168] child.c(399): AH00334: Child: Accept thread listening on 0.0.0.0:8080 using AcceptFilter data
[Mon Nov 13 18:56:19.859012 2017] [mpm_winnt:debug] [pid 45568:tid 1176] child.c(399): AH00334: Child: Accept thread listening on [::]:8080 using AcceptFilter data

Note:

I am using:

- Windows server 2012 RC (64bit)

- Apache version 2.4.23 (64bit) within mod_wsgi.so (64bit)

- ArcGIS Pro version 1.3 (Python version 3.4.4) 64bit

===================================================================

Other way to start my application that I don't need Apache, I mean I run directly my python file in Windows command prompt like python index.py

Everything works well.


Thank a lot.

0 Kudos
0 Replies