From 977c6ca85e6ecba709e07cea0acb9fbc2c9495c6 Mon Sep 17 00:00:00 2001 From: 1C4nfaN Date: Fri, 13 Oct 2023 10:53:09 +0800 Subject: [PATCH] fix:avoid global operate --- tests/test_oneway.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_oneway.py b/tests/test_oneway.py index bcee32e..812cfda 100644 --- a/tests/test_oneway.py +++ b/tests/test_oneway.py @@ -11,14 +11,14 @@ def Test(self, req): assert req == "Hello!" -oneway_thrift = thriftpy2.load("oneway.thrift", module_name="oneway_thrift") -multiprocessing.set_start_method("fork") +class TestOneway(object): + oneway_thrift = thriftpy2.load("oneway.thrift") -class TestOneway(object): def setup_class(self): - server = make_server(oneway_thrift.echo, Dispatcher(), '127.0.0.1', 6000) - self.p = multiprocessing.Process(target=server.serve) + ctx = multiprocessing.get_context("fork") + server = make_server(self.oneway_thrift.echo, Dispatcher(), '127.0.0.1', 6000) + self.p = ctx.Process(target=server.serve) self.p.start() time.sleep(1) # Wait a second for server to start. @@ -27,6 +27,6 @@ def teardown_class(self): def test_echo(self): req = "Hello!" - client = make_client(oneway_thrift.echo, '127.0.0.1', 6000) + client = make_client(self.oneway_thrift.echo, '127.0.0.1', 6000) assert client.Test(req) == None