diff -ur Python-2.6.4/Modules/posixmodule.c Python-2.6.4.patched/Modules/posixmodule.c --- Python-2.6.4/Modules/posixmodule.c 2009-09-16 16:06:36.000000000 -0400 +++ Python-2.6.4.patched/Modules/posixmodule.c 2010-01-22 10:00:18.000000000 -0500 @@ -3634,11 +3634,12 @@ int result; _PyImport_AcquireLock(); pid = fork1(); + if (pid == 0) + PyOS_AfterFork(); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); - if (pid == 0) - PyOS_AfterFork(); if (result < 0) { /* Don't clobber the OSError if the fork failed. */ PyErr_SetString(PyExc_RuntimeError, @@ -3663,11 +3664,12 @@ int result; _PyImport_AcquireLock(); pid = fork(); + if (pid == 0) + PyOS_AfterFork(); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); - if (pid == 0) - PyOS_AfterFork(); if (result < 0) { /* Don't clobber the OSError if the fork failed. */ PyErr_SetString(PyExc_RuntimeError, @@ -3781,11 +3783,12 @@ _PyImport_AcquireLock(); pid = forkpty(&master_fd, NULL, NULL, NULL); + if (pid == 0) + PyOS_AfterFork(); + result = _PyImport_ReleaseLock(); if (pid == -1) return posix_error(); - if (pid == 0) - PyOS_AfterFork(); if (result < 0) { /* Don't clobber the OSError if the fork failed. */ PyErr_SetString(PyExc_RuntimeError, diff -ur Python-2.6.4/Python/import.c Python-2.6.4.patched/Python/import.c --- Python-2.6.4/Python/import.c 2009-09-16 16:06:36.000000000 -0400 +++ Python-2.6.4.patched/Python/import.c 2010-01-26 07:03:14.000000000 -0500 @@ -303,10 +303,9 @@ void _PyImport_ReInitLock(void) { -#ifdef _AIX if (import_lock != NULL) import_lock = PyThread_allocate_lock(); -#endif + import_lock_thread = PyThread_get_thread_ident(); } #endif