From a488a4b4fc23615ec96145865acc74357d4f0891 Mon Sep 17 00:00:00 2001 From: Oseas Andre Date: Mon, 7 Sep 2026 14:09:52 -0300 Subject: [PATCH 1/5] refactor: add port in server constructor. And remove auto ip identification and binding --- .../python/server_python_stub_generator.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/srpcLib/stub_generator/python/server_python_stub_generator.py b/srpcLib/stub_generator/python/server_python_stub_generator.py index eab22ee..9fa7c40 100644 --- a/srpcLib/stub_generator/python/server_python_stub_generator.py +++ b/srpcLib/stub_generator/python/server_python_stub_generator.py @@ -3,7 +3,6 @@ from ...interface.srpc_stub_generator_interface import SrpcStubGeneratorInterface from ...utils.srpc_stub import ( - DEFAULT_CONNECTION_PORT, LIB_NAME, get_service_interface_class_name, get_service_name, @@ -89,14 +88,10 @@ def generate_stub(self, dest_path: str = None): from {service_name}.{service_name}_interface import {service_interface_class_name} class Srpc{service_name.capitalize()}ServerStub(SrpcServerStubInterface): - def __init__(self, tls_config: SrpcTLSConfig = None, host:str=None, num_threads = 8): + def __init__(self, tls_config: SrpcTLSConfig = None, host:str="127.0.0.1", port = 5000 ,num_threads = 8): - if host == None: - self.__host = srpcnetwork.get_lan_ip_or_localhost() - else: - self.__host = host - - self.__CONNECTION_PORT = {DEFAULT_CONNECTION_PORT} + self.__host = host + self.__CONNECTION_PORT = port self.__handler_threads_pool = ThreadPoolExecutor(max_workers=num_threads) From 0bc150897258acc906594356d389afd9a6a7dcb6 Mon Sep 17 00:00:00 2001 From: Oseas Andre Date: Mon, 7 Sep 2026 14:11:25 -0300 Subject: [PATCH 2/5] refactor: adjust tests --- tests/integration/simple_project/client.py | 4 ++-- .../simple_project/run_rpc_client_divizion_by_zero.py | 4 +--- tests/integration/test_simple_project.py | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/integration/simple_project/client.py b/tests/integration/simple_project/client.py index 3f6f152..172e31b 100644 --- a/tests/integration/simple_project/client.py +++ b/tests/integration/simple_project/client.py @@ -1,8 +1,8 @@ from srpc_calc_client_stub import SrpcCalcClientStub -from srpcLib.utils.srpc_network import get_lan_ip_or_localhost +# from srpcLib.utils.srpc_network import get_lan_ip_or_localhost -SERVER_HOST = get_lan_ip_or_localhost() +SERVER_HOST = "127.0.0.1" calcStub = SrpcCalcClientStub(SERVER_HOST, 5000) a = 4 b = 2 diff --git a/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py b/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py index 43030d9..bd06590 100644 --- a/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py +++ b/tests/integration/simple_project/run_rpc_client_divizion_by_zero.py @@ -1,8 +1,6 @@ from srpc_calc_client_stub import SrpcCalcClientStub -from srpcLib.utils.srpc_network import get_lan_ip_or_localhost - -SERVER_HOST = get_lan_ip_or_localhost() +SERVER_HOST = "127.0.0.1" calcStub = SrpcCalcClientStub(SERVER_HOST, 5000) a = 4 try: diff --git a/tests/integration/test_simple_project.py b/tests/integration/test_simple_project.py index f9fdaee..3eddd93 100644 --- a/tests/integration/test_simple_project.py +++ b/tests/integration/test_simple_project.py @@ -6,8 +6,6 @@ import pytest -from srpcLib.utils.srpc_network import get_lan_ip_or_localhost - # Paths ROOT_DIR = Path(__file__).resolve().parents[2] # rpc-lib/ TEST_PROJECT = ROOT_DIR / "tests/integration/simple_project" @@ -22,7 +20,8 @@ CLIENT_SCRIPT_DIVISION_BY_ZERO = "run_rpc_client_divizion_by_zero.py" # Network -SERVER_HOST = get_lan_ip_or_localhost() +# SERVER_HOST = get_lan_ip_or_localhost() +SERVER_HOST = "127.0.0.1" SERVER_PORT = 5000 From 3bbc4c917ceb5b89d8e378b63a1ed62372a3ca75 Mon Sep 17 00:00:00 2001 From: Oseas Andre Date: Mon, 7 Sep 2026 14:29:59 -0300 Subject: [PATCH 3/5] refactor: adjust tests --- tests/integration/project_with_tls/server.py | 2 +- tests/integration/test_simple_project.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/project_with_tls/server.py b/tests/integration/project_with_tls/server.py index 2fd81f0..3b5cfca 100644 --- a/tests/integration/project_with_tls/server.py +++ b/tests/integration/project_with_tls/server.py @@ -1,5 +1,5 @@ from srpc_calc_server_stub import SrpcCalcServerStub, SrpcTLSConfig tls_config = SrpcTLSConfig(certfile="./server.crt", keyfile="./server.key") -srpc_server = SrpcCalcServerStub(tls_config, "127.0.0.1") +srpc_server = SrpcCalcServerStub(tls_config=tls_config, host="127.0.0.1") srpc_server.start() diff --git a/tests/integration/test_simple_project.py b/tests/integration/test_simple_project.py index 3eddd93..c276f59 100644 --- a/tests/integration/test_simple_project.py +++ b/tests/integration/test_simple_project.py @@ -20,7 +20,6 @@ CLIENT_SCRIPT_DIVISION_BY_ZERO = "run_rpc_client_divizion_by_zero.py" # Network -# SERVER_HOST = get_lan_ip_or_localhost() SERVER_HOST = "127.0.0.1" SERVER_PORT = 5000 From b7739e9bd29ddd7fbeb4382a56e9bbb1777afe0b Mon Sep 17 00:00:00 2001 From: Oseas Andre Date: Mon, 7 Sep 2026 14:34:17 -0300 Subject: [PATCH 4/5] refactor: adjust tests --- tests/integration/test_project_with_tls.py | 2 +- tests/integration/test_simple_project.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_project_with_tls.py b/tests/integration/test_project_with_tls.py index 132c505..bc458ed 100644 --- a/tests/integration/test_project_with_tls.py +++ b/tests/integration/test_project_with_tls.py @@ -33,7 +33,7 @@ def wait_for_server(host, port, timeout=5.0): raise RuntimeError("Server did not start in time") -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="function") def install_lib(): """ Install the library into the test_project virtual environment context. diff --git a/tests/integration/test_simple_project.py b/tests/integration/test_simple_project.py index c276f59..925766b 100644 --- a/tests/integration/test_simple_project.py +++ b/tests/integration/test_simple_project.py @@ -35,7 +35,7 @@ def wait_for_server(host, port, timeout=5.0): raise RuntimeError("Server did not start in time") -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="function") def install_lib(): """ Install the library into the test_project virtual environment context. From a0a9e18e2e98aba8a8532faac0d3a2cf95c0b0c2 Mon Sep 17 00:00:00 2001 From: Oseas Andre Date: Mon, 7 Sep 2026 14:38:23 -0300 Subject: [PATCH 5/5] refactor: adjust tests --- tests/integration/test_project_with_tls.py | 6 +++--- tests/integration/test_simple_project.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/integration/test_project_with_tls.py b/tests/integration/test_project_with_tls.py index bc458ed..c3e2c2d 100644 --- a/tests/integration/test_project_with_tls.py +++ b/tests/integration/test_project_with_tls.py @@ -33,7 +33,7 @@ def wait_for_server(host, port, timeout=5.0): raise RuntimeError("Server did not start in time") -@pytest.fixture(scope="function") +@pytest.fixture(scope="session", autouse=True) def install_lib(): """ Install the library into the test_project virtual environment context. @@ -45,7 +45,7 @@ def install_lib(): ) -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="function") def generate_stubs(): """ Run the stub generator as a CLI tool inside test_project. @@ -95,7 +95,7 @@ def generate_stubs(): return TEST_PROJECT -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def server_process(generate_stubs, request): """ Launch the server once for the entire test session. diff --git a/tests/integration/test_simple_project.py b/tests/integration/test_simple_project.py index 925766b..ae89027 100644 --- a/tests/integration/test_simple_project.py +++ b/tests/integration/test_simple_project.py @@ -35,7 +35,7 @@ def wait_for_server(host, port, timeout=5.0): raise RuntimeError("Server did not start in time") -@pytest.fixture(scope="function") +@pytest.fixture(scope="session", autouse=True) def install_lib(): """ Install the library into the test_project virtual environment context. @@ -47,7 +47,7 @@ def install_lib(): ) -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="function") def generate_stubs(): """ Run the stub generator as a CLI tool inside test_project. @@ -97,7 +97,7 @@ def generate_stubs(): return TEST_PROJECT -@pytest.fixture(scope="session") +@pytest.fixture(scope="function") def server_process(generate_stubs, request): """ Launch the server once for the entire test session.