summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_bio_membuf.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/test_bio_membuf.py b/tests/test_bio_membuf.py
index 16e9c03..6fe5120 100644
--- a/tests/test_bio_membuf.py
+++ b/tests/test_bio_membuf.py
@@ -7,6 +7,9 @@ Copyright (c) 2000 Ng Pheng Siong. All rights reserved."""
import os
import multiprocessing
+from platform import system
+from sys import version_info
+from M2Crypto import six
from M2Crypto.BIO import MemoryBuffer
from tests import unittest
@@ -16,7 +19,23 @@ class TimeLimitExpired(Exception):
def time_limit(timeout, func, exc_msg, *args, **kwargs):
- p = multiprocessing.Process(target=func)
+
+ # multiprocessing.get_context() available in Python >= 3.4
+ if six.PY3:
+ # Python >=3.8 on MacOS changed start_method to 'spawn' as default.
+ # This creates a new context with the previous 'fork'
+ # start_method. Fixes issue #286.
+ if system() == 'Darwin' and version_info.major >= 3 and version_info.minor >= 8:
+ start_method = 'fork'
+ else:
+ # use default context
+ start_method = None
+
+ mp = multiprocessing.get_context(start_method)
+ else:
+ mp = multiprocessing
+
+ p = mp.Process(target=func)
p.start()
p.join(timeout)
if p.is_alive():