From faae760e154f4dda73957cc6c174b8842f3c0932 Mon Sep 17 00:00:00 2001 From: cocolato Date: Tue, 16 Apr 2024 20:21:34 +0800 Subject: [PATCH] force use fork mode to start multiprocess in test --- tests/test_all_protocols_binary_field.py | 2 ++ tests/test_apache_json.py | 3 +++ tests/test_buffered_transport.py | 2 ++ tests/test_http.py | 2 ++ tests/test_multiplexed.py | 2 ++ tests/test_oneway.py | 2 ++ tests/test_protocol_cybinary.py | 2 ++ tests/test_rpc.py | 1 + tests/test_tracking.py | 1 + 9 files changed, 17 insertions(+) diff --git a/tests/test_all_protocols_binary_field.py b/tests/test_all_protocols_binary_field.py index e75e141..1f0a20a 100644 --- a/tests/test_all_protocols_binary_field.py +++ b/tests/test_all_protocols_binary_field.py @@ -3,6 +3,7 @@ import sys import time import traceback +import multiprocessing from multiprocessing import Process import pytest @@ -25,6 +26,7 @@ make_client as make_rpc_client from thriftpy2.transport import TBufferedTransportFactory, TCyMemoryBuffer +multiprocessing.set_start_method("fork", force=True) if sys.platform == "win32": pytest.skip("requires fork", allow_module_level=True) diff --git a/tests/test_apache_json.py b/tests/test_apache_json.py index 85844e1..efc4012 100644 --- a/tests/test_apache_json.py +++ b/tests/test_apache_json.py @@ -4,6 +4,7 @@ import json import sys import time +import multiprocessing from multiprocessing import Process import pytest @@ -19,6 +20,8 @@ from thriftpy2.transport import TMemoryBuffer from thriftpy2.transport.buffered import TBufferedTransportFactory +multiprocessing.set_start_method("fork", force=True) + def recursive_vars(obj): if isinstance(obj, six.string_types): diff --git a/tests/test_buffered_transport.py b/tests/test_buffered_transport.py index 69cd715..08d4499 100644 --- a/tests/test_buffered_transport.py +++ b/tests/test_buffered_transport.py @@ -19,6 +19,8 @@ from thriftpy2._compat import CYTHON logging.basicConfig(level=logging.INFO) +multiprocessing.set_start_method("fork", force=True) + addressbook = thriftpy2.load(path.join(path.dirname(__file__), "addressbook.thrift")) diff --git a/tests/test_http.py b/tests/test_http.py index 6d7493a..8ee65fd 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -18,6 +18,8 @@ from thriftpy2.http import make_server, make_client, client_context, THttpHeaderFactory # noqa from thriftpy2.thrift import TApplicationException # noqa +multiprocessing.set_start_method("fork", force=True) + addressbook = thriftpy2.load(os.path.join(os.path.dirname(__file__), "addressbook.thrift")) diff --git a/tests/test_multiplexed.py b/tests/test_multiplexed.py index 3f38abf..be6ab54 100644 --- a/tests/test_multiplexed.py +++ b/tests/test_multiplexed.py @@ -20,6 +20,8 @@ from thriftpy2.transport import TBufferedTransportFactory, TServerSocket +multiprocessing.set_start_method("fork", force=True) + if sys.platform == "win32": pytest.skip("requires fork", allow_module_level=True) diff --git a/tests/test_oneway.py b/tests/test_oneway.py index fcf88ba..afeb0a2 100644 --- a/tests/test_oneway.py +++ b/tests/test_oneway.py @@ -8,6 +8,8 @@ from thriftpy2.rpc import make_client, make_server +multiprocessing.set_start_method("fork", force=True) + if sys.platform == "win32": pytest.skip("requires fork", allow_module_level=True) diff --git a/tests/test_protocol_cybinary.py b/tests/test_protocol_cybinary.py index 4bc8f7e..7725d11 100644 --- a/tests/test_protocol_cybinary.py +++ b/tests/test_protocol_cybinary.py @@ -19,6 +19,8 @@ else: pytest.skip("cython not enabled.", allow_module_level=True) +multiprocessing.set_start_method("fork", force=True) + class TItem(TPayload): thrift_spec = { diff --git a/tests/test_rpc.py b/tests/test_rpc.py index e7b2283..a6e3f4f 100644 --- a/tests/test_rpc.py +++ b/tests/test_rpc.py @@ -19,6 +19,7 @@ from thriftpy2.transport import TTransportException # noqa from thriftpy2.thrift import TApplicationException # noqa +multiprocessing.set_start_method("fork", force=True) if sys.platform == "win32": pytest.skip("requires unix domain socket", allow_module_level=True) diff --git a/tests/test_tracking.py b/tests/test_tracking.py index 9d71d4d..602891c 100644 --- a/tests/test_tracking.py +++ b/tests/test_tracking.py @@ -58,6 +58,7 @@ else: cleanup_on_sigterm() +multiprocessing.set_start_method("fork", force=True) if sys.platform == "win32": pytest.skip("requires fork", allow_module_level=True)