Cherrypy with arcpy

2473
14
01-19-2017 02:03 AM
Thanh_NgocDao
New Contributor

Hello everybody,

Currently i'm developing an API that do some basic calculation (polygon area ... ) using arcpy. I'm using bottle.py with cherrypy as webserver.

At first i used the WSGIRef (default webserver of bottle.py, single-thread) and everything is fine but after switching to cherrypy (multi-threaed webserver), my code suddenly went down, look closely in to my source code it fail in these line:

             arcpy.env.workspace = OutputLocation

Have someone ever facing this problem before?

0 Kudos
14 Replies
Thanh_NgocDao
New Contributor

In fact it raise the error at that step and the error is: AttributeError: ERROR 87934 ... As i know usually AttributeError is raised because there is no that attribute (env or workspace)

0 Kudos
DanPatterson_Retired
MVP Emeritus

so, to summarize,

  • arcpy imports fine, so arcpy can be seen
  • you say that the workspace if fine (correct?) but arcpy says otherwise...

then according to arcpy, it is not a valid workspace, so proceeding on to the next logical step of trying to query a folder or a geodatabase in the workspace isn't possible until that step is resolved.  Does that pretty well summarize the state so far?

PS it wouldn't be one of those network induced absolute vs relative path issues would it?

0 Kudos
Thanh_NgocDao
New Contributor

I'm sorry if my comment is not clear. Here is the situation:

+ Arcpy import fine

+ arcpy.env.workspace = OutputLocation raise AttributeError, after a few search on Google somebody say that AttributeError occurs because that attribute is not exist (i mean there is no workspace attribute in env or there is no env attribute in arcpy). But the weird thing is that this code run fine if i use the WSGIRef webserver (single thread webserver) or run it as stand-alone script but after switching to Cherrypy webserver (multi-thread) my code does not work anymore and the stack trace point to this line: arcpy.env.workspace = OutputLocation 

I have tried on both relative path and absolute path but it does not help.

P/S: There is an topic state that Arcpy does not compatible with multi-thread webserver, is it true ?

0 Kudos
DanPatterson_Retired
MVP Emeritus

That thread would be a useful addition to the discussion... why don't you post the link.  If it was found to be an issue or stated as one... good chance it isn't compatible or you need python 3.x or PRO or background processing installed.  could be any combination of factors

Good luck

0 Kudos
Thanh_NgocDao
New Contributor

This is the thread i found:

https://community.esri.com/thread/99374 

Currently i use Arcgis PRO with Python 3 but that error happen

0 Kudos