Select to view content in your preferred language

Passing objects into (and out of) a subprocess (Python)

16149
10
11-10-2010 02:52 AM
jamessample
Emerging Contributor
This is essentially a repeat of Chris Snyder's 2006 post on the old forum (http://forums.esri.com/Thread.asp?c=93&f=1729&t=193431&mc=0#msgid575153). It didn't get any replies back then; I'm hoping for better luck 🙂

Does anyone have any examples of using the subprocess module to pass objects into a slave script and then get the results back to the parent script?

I've seen some examples which pass file paths (as strings) into the slave script, but I really need to have the slave script manipulate numpy arrays declared in the parent script, then pass the results back out again (again as numpy arrays). Is this possible?

Thanks!
0 Kudos
10 Replies
ChrisSnyder
Honored Contributor
If anyone is interested - here's an update of my os.spwanv psudo-parallel process method but now ***new and improved***using the subprocess module and better/fancier coding methods. It doesn't include any robust method (other than simple strings and return codes) of comunicating between parent and child processes but it could be altered to do that using the provided subprocess.Popen object (I guess via the .stdin method?). I'd be super happy to have someone smart show me how to elaborate on my simple example to include fancy stuff like handing numpy arrays to the child process or sending dictionary objects back to the parent script - something fancy like that! I am not there yet, but will probably have the need to do this eventually. For now it's a first stab and accomplishes what I need it to do...

Here's the link: http://forums.arcgis.com/threads/33602-Arcpy-Multiprocessor-issues?p=177418&viewfull=1#post177418
0 Kudos