<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ‘Could not open SDE workspace’ Error when running Multithreaded Calls on a geoprocessing service in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/could-not-open-sde-workspace-error-when-running/m-p/1229489#M6400</link>
    <description>&lt;P&gt;Did you ever find a work around for this issue. We occasionally experience a similar error message in a python script that uses an sde connection to an Enterprise geodatabase, this process runs every 15 minutes and about 1-2 times per day we see this.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Nov 2022 13:28:02 GMT</pubDate>
    <dc:creator>PaulCyr1</dc:creator>
    <dc:date>2022-11-08T13:28:02Z</dc:date>
    <item>
      <title>‘Could not open SDE workspace’ Error when running Multithreaded Calls on a geoprocessing service</title>
      <link>https://community.esri.com/t5/developers-questions/could-not-open-sde-workspace-error-when-running/m-p/1160803#M6237</link>
      <description>&lt;P&gt;Hi. I have a python based geoprocessing service running on arcgis server 10.8 which is deployed on several environments. There is an application that makes multithreaded calls (roughly 9 calls concurrently) but about 2 or 3 will fail every time. I get one of the following 4 errors:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Error executing tool. {Name of Tool} &amp;nbsp;: Could not open SDE workspace. or RuntimeError: Object: Could not open SDE workspace {Path to sde}/testgis.sde&lt;/LI&gt;&lt;LI&gt;Connection information provided was for a non-administrative user&lt;/LI&gt;&lt;LI&gt;RuntimeError: cannot open {Path to sde}\GIS.sde\GIS.DBO.TravelPolygons\GIS.DBO.TP_SITES_60'&lt;/LI&gt;&lt;LI&gt;Error executing tool. {Name of Tool}: ERROR 000229: Cannot open {Path to sde}\GIS.sde\GIS.DBO.Designation_PC&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Usually the service will fail at the first time the script tries to connect/query a database table sometimes at the second or third time it tries to connect (bullet 3 or 4). I do not get any error if a single call is made and it is only happening in our production environment. The concurrent calls work in our lower environments. &amp;nbsp;My theory so far is that the concurrent calls may be causing locks which prevents a few of the threads from connecting to the database. Adding a delay is not an option on the application side. I have tried to adding a random delay right before it connects using the sde in the geoprocessing service code but it has not worked consistently. Does anyone know a way to get around the locks or any database settings that could be changed?&lt;/P&gt;&lt;P&gt;below are the two functions where the errors typically occur:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def getCTfromTable (x,y,minutes):

    tableName = g_CT_Table_Name
    isFound = False
    Cts=''
    expression = 'lat ='+str(y) +' and  long='+str(x) +' and traveltime = '+str(minutes)
    arcpy.AddMessage("where clause CT " + expression)


    g_CT_Full_Path = os.path.join(g_SDE_Location,g_CT_Table_Name)
    arcpy.AddMessage (g_CT_Full_Path)
    with arcpy.da.SearchCursor(g_CT_Full_Path, ['OBJECTID','lat','long', 'cts'], expression) as cursor:
            isFound = True
            for row in cursor:
                Cts = row

    return Cts

def getTPfromtable(x,y,minutes):
    tp = None
    tableName = "TP_sites_"+minutes
    expression ='latitude ='+str(y) +' and longitude='+str(x)

    isFound = False
    arcpy.AddMessage("where clause TP " + expression)

    g_TP_Table_1 =  g_TP_Table+str(int(minutes))
    layerpPath = os.path.join(g_SDE_Location,g_TP_Table_1)
    arcpy.AddMessage(" TP table " +layerpPath)
    arcpy.AddMessage("Expression .... " + expression)
    with arcpy.da.SearchCursor(layerpPath, ['Shape@'], expression) as cursor:

            for row in cursor:
                isFound = True
                arcpy.AddMessage("line TP FOUND IN THE TABLE... ")

                tp = row[0]
    if isFound == False:
         preResult = AutoPreprocess.preprocess(y,x)
         arcpy.AddMessage ("NOT FOUND IN TP - PREPROCESSED RAN")
         with arcpy.da.SearchCursor(layerpPath, ['Shape@'], expression) as cursor:

            for row in cursor:
                isFound = True
                arcpy.AddMessage("FOUND AFTER PREPROCESSED... ")

                tp = row[0]


    return tp&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 15:36:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/could-not-open-sde-workspace-error-when-running/m-p/1160803#M6237</guid>
      <dc:creator>mayronajarro2</dc:creator>
      <dc:date>2022-04-04T15:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: ‘Could not open SDE workspace’ Error when running Multithreaded Calls on a geoprocessing service</title>
      <link>https://community.esri.com/t5/developers-questions/could-not-open-sde-workspace-error-when-running/m-p/1229489#M6400</link>
      <description>&lt;P&gt;Did you ever find a work around for this issue. We occasionally experience a similar error message in a python script that uses an sde connection to an Enterprise geodatabase, this process runs every 15 minutes and about 1-2 times per day we see this.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 13:28:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/could-not-open-sde-workspace-error-when-running/m-p/1229489#M6400</guid>
      <dc:creator>PaulCyr1</dc:creator>
      <dc:date>2022-11-08T13:28:02Z</dc:date>
    </item>
  </channel>
</rss>

