Skip to content

Commit

Permalink
fix:avoid global operate
Browse files Browse the repository at this point in the history
  • Loading branch information
1C4nfaN authored and aisk committed Oct 23, 2023
1 parent 7ede4a6 commit 977c6ca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/test_oneway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

0 comments on commit 977c6ca

Please sign in to comment.