Here's an update on what I've tried. If I modify ___cleanup to:
-----------------------------------------------------
___EXP_FUNC(void,___cleanup) ___PVOID { /* * Only do cleanup once after successful setup. */
printf ("setup_state : %i \n" , setup_state); fflush (stdout); sleep(200); setup_state = 1;
if (setup_state != 1) return;
setup_state = 2;
___cleanup_mem (); ___cleanup_os (); }
-----------------------------------------------------
and call Python does not exit. However, the code neither prints nor sleeps (it does print and sleep when I try test8). I can make setup_state = 1; any number I want and call ___cleanup any number of times. After I setup the environment as in client.c (test8), Python crashes after a call to ___cleanup. The same thing happens if I make a standalone program with Cython. I'm going to see if I can get any help from the Cython folks.
-Dave