diff --git a/tests/appsec/contrib_appsec/test_fastapi.py b/tests/appsec/contrib_appsec/test_fastapi.py index 027013eb8ca..3638d9a5c0d 100644 --- a/tests/appsec/contrib_appsec/test_fastapi.py +++ b/tests/appsec/contrib_appsec/test_fastapi.py @@ -15,7 +15,7 @@ class Test_FastAPI(utils.Contrib_TestClass_For_Threats): @pytest.fixture - def interface(self, tracer, printer): + def interface(self, printer): from fastapi.testclient import TestClient # for fastapi, test tracer needs to be set before the app is created diff --git a/tests/utils.py b/tests/utils.py index 70193d61293..a63e00315f9 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -644,6 +644,10 @@ def pop(self): spans = DummyWriterMixin.pop(self) if self._trace_flush_enabled: flush_test_tracer_spans(self) + # Stop the writer threads in case the writer is no longer used. + # Otherwise we risk accumulating threads and file descriptors causing crashes + # In case the writer is used again it will be restarted by native side. + self._inner_writer.before_fork() return spans def recreate(self, appsec_enabled: Optional[bool] = None) -> "DummyWriter":