Browse code

app_python3: for Python >= 3.7 call pre-fork hook

(cherry picked from commit 138ef5630402448ea2643097a3d25d4dcead6d70)

Anthony Alba authored on 05/11/2021 09:31:34
Showing 1 changed files
... ...
@@ -175,6 +175,17 @@ static int mod_init(void)
175 175
 static int child_init(int rank)
176 176
 {
177 177
 	if(rank==PROC_INIT) {
178
+		/*
179
+		 * this is called before any process is forked
180
+		 * so the Python internal state handler
181
+		 * should be called now.
182
+		 *
183
+		 * TODO: is PyOS_AfterFork_Parent() necesary
184
+		 * in the main process?
185
+		 */
186
+#if PY_VERSION_HEX >= 0x03070000
187
+		PyOS_BeforeFork() ;
188
+#endif
178 189
 		return 0;
179 190
 	}
180 191
 	_apy_process_rank = rank;