UPDATE:
I tested Luke's code, and the message I receive tellS me the process was successful, but still I get nothing written out to disk:
import os, arcpy, arcgisscripting, time, sys
from multiprocessing import Process
from multiprocessing.queues import SimpleQueue
copy_dir = r'D:\test3'
gdb_dir = copy_dir+'\\'+'CAD_Export_to_GDB'
def ConvertCADtoGDB(msgs,in_dgn,out_gdb):
try:
gp = arcgisscripting.create()
gp.ImportCAD_conversion(in_dgn,out_gdb,'','Explode_Complex')
if not arcpy.Exists(out_gdb):raise RuntimeError('%s does not exist'%out_gdb)
msgs.put(gp.GetMessages())
except Exception as err:
msgs.put(gp.GetMessages())
msgs.put(err)
def main(srch_dir,gdb_dir,timeout):
for dirpath, dirnames, files in os.walk(srch_dir):
for f in files:
f_name, f_ext = os.path.splitext(f)
in_dgn = os.path.join(dirpath,f)
out_gdb = os.path.join(gdb_dir,f_name+'.gdb')
if f_ext == '.dgn':
if not os.path.isdir(out_gdb):
print 'creating',out_gdb
#####################################################
# Create a separate process to run the tool in
# and a Queue to pass messages back
m = SimpleQueue()
p = Process(target=ConvertCADtoGDB,
args=(m,in_dgn,out_gdb))
p.start()
p.join(timeout) # Wait for process to complete
err = None
while not m.empty(): # Check if messages in queue
msg = m.get()
if isinstance(msg, Exception):err= msg
else: print msg
if p.is_alive(): # Terminate process if it is
p.terminate() # still running after the timeout
print('terminated')
elif err:
print('unsuccessful: %s'%err)
else:
print('successful')
#####################################################
if __name__ == '__main__':
srch_dir=r'C:\Temp\dgns'
gdb_dir=r'C:\Temp\gdbs'
timeout=60 #Seconds
main(copy_dir,gdb_dir,timeout)