Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I attempted to spawn a separate process from the ArcGIS ToolValidator script. Unfortunately, it launches another instance of ArcCatalog.

  1. What is going on behind the scenes that causes ArcCatalog to be launched, when I'm only trying to execute a second python script in a separate process and get the results?

  2. How can I launch a separate process, wait for it to end, and get the results (standard out)?

Don't worry, I'm not trying to do heavy lifting from inside the tool dialog. I was just trying to bypass the background processing window when calling GetCount_management. That problem was solved, but I'm still curious why ArcCatalog gets launched.

share|improve this question
What syntax and parameters are you using to spawn the subprocess? i.e. are you using sys.executable to try and get the path to the python executable (which won't work when running from ArcCatalog)? Can you post a simple example? – Luke Nov 24 '11 at 0:01
I used with a path to an existing python script. I just did some tests I tossed, I'll set it up again if you have suggestions to try. – Michael A. Jackson Nov 24 '11 at 0:37

The following works for me in a ToolValidator class:

import sys,subprocess,os.path[os.path.join(sys.exec_prefix,'pythonw'),path_to_script, script_arg_1,...,script_arg_N])
share|improve this answer

If you are looking to execute a piece of code rather than a whole script, it might be worth your while to look at the Multiprocessing module.

It will create a new process with separate resources, though still allowing you to share information between processes, if you so choose. The typical frame for this would be:

import multiprocessing as _mp

def _target(var1, var2):
    import arcpy #(if required) 
    #do work here

def main():
    process = _mp.Process(target=target, kwargs=(var1='data', var2='data')

    except Exception, ex:
        print ex

if you would like to transfer data between the processes, check out the python multiprocessing pages

share|improve this answer
Just to add, I have no idea why ArcCatalog would need to spawn a second instance. I guess its just a feature! – OptimizePrime Nov 24 '11 at 20:52
Thanks. I started with the multiprocessing module, and it also launches an instance of ArcCatalog. I'll get my tests set up again and respond back... – Michael A. Jackson Nov 28 '11 at 20:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.