开发的项目中需要在新线程中判断一条路径的工作空间类型为文件夹还是gdb数据库,但是arcpy.Describe()函数在新线程中报错。特来求助!代码示例如下:
# -*- coding: utf-8 -*- import arcpy import threading wkpath = "F:/Desktop/data.gdb" def pathtype(): desc = arcpy.Describe(wkpath) print("工作目录类型为:" + desc.workspaceType) def thread_it(func, *args): t = threading.Thread(target = func, args = args) t.setDaemon(False) t.start() thread_it(pathtype)
这个目录是真实存在的,但报错说这个目录不存在:
Exception in thread Thread-1: Traceback (most recent call last): File "C:\Python27\ArcGIS10.7\lib\threading.py", line 801, in __bootstrap_inner Custom Domain by Bitly() File "C:\Python27\ArcGIS10.7\lib\threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "F:\Desktop\test2.py", line 9, in pathtype desc = arcpy.Describe(wkpath) File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\__init__.py", line 1260, in Describe return gp.describe(value, data_type) File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\geoprocessing\_base.py", line 376, in describe self._gp.Describe(*gp_fixargs(args, True))) IOError: "F:/Desktop/data.gdb" does not exist