This is an automated email from the ASF dual-hosted git repository.
wu-sheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
The following commit(s) were added to refs/heads/master by this push:
new c3e4c89 perf(demo): set a timeout on flask consumer fork HTTP calls
(#388)
c3e4c89 is described below
commit c3e4c89b8c0142bc91ae777628ccbc51547b1f2f
Author: Mohammed Basheeruddin <[email protected]>
AuthorDate: Thu Jun 25 05:49:04 2026 -0400
perf(demo): set a timeout on flask consumer fork HTTP calls (#388)
---
demo/flask_consumer_fork.py | 2 +-
tests/e2e/base/consumer/flask_consumer.py | 2 +-
tests/plugin/base.py | 14 ++---
tests/plugin/http/sw_httpx/services/consumer.py | 78 ++++++++++++-------------
4 files changed, 47 insertions(+), 49 deletions(-)
diff --git a/demo/flask_consumer_fork.py b/demo/flask_consumer_fork.py
index 6981f9a..7894735 100644
--- a/demo/flask_consumer_fork.py
+++ b/demo/flask_consumer_fork.py
@@ -38,7 +38,7 @@ app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def application():
- res = requests.get('http://localhost:9999')
+ res = requests.get('http://localhost:9999', timeout=10.0)
return res.json()
diff --git a/tests/e2e/base/consumer/flask_consumer.py
b/tests/e2e/base/consumer/flask_consumer.py
index d1fe220..844ea68 100644
--- a/tests/e2e/base/consumer/flask_consumer.py
+++ b/tests/e2e/base/consumer/flask_consumer.py
@@ -31,7 +31,7 @@ def artist():
try:
time.sleep(random.random())
payload = request.get_json()
- requests.post('http://provider:9090/artist-provider', data=payload)
+ requests.post('http://provider:9090/artist-provider', data=payload,
timeout=10.0)
return {'artist': 'song'}
except Exception as e: # noqa
diff --git a/tests/plugin/base.py b/tests/plugin/base.py
index fbea29b..7951a69 100644
--- a/tests/plugin/base.py
+++ b/tests/plugin/base.py
@@ -41,17 +41,15 @@ class TestPluginBase:
with open(expected_file_name) as expected_data_file:
expected_data = os.linesep.join(expected_data_file.readlines())
- response =
requests.post(url='http://localhost:12800/dataValidate', data=expected_data)
+ response =
requests.post(url='http://localhost:12800/dataValidate', data=expected_data,
timeout=10.0)
- # Retry with backoff — segments may not have been reported yet
- for i in range(3):
- if response.status_code == 200:
- break
- time.sleep(5 * (i + 1))
- response =
requests.post(url='http://localhost:12800/dataValidate', data=expected_data)
+ if response.status_code != 200:
+ # heuristically retry once
+ time.sleep(10)
+ response =
requests.post(url='http://localhost:12800/dataValidate', data=expected_data,
timeout=10.0)
if response.status_code != 200:
- res = requests.get('http://localhost:12800/receiveData')
+ res = requests.get('http://localhost:12800/receiveData',
timeout=10.0)
actual_data = yaml.dump(yaml.load(res.content, Loader=Loader))
diff --git a/tests/plugin/http/sw_httpx/services/consumer.py
b/tests/plugin/http/sw_httpx/services/consumer.py
index b096ca1..482f8d2 100644
--- a/tests/plugin/http/sw_httpx/services/consumer.py
+++ b/tests/plugin/http/sw_httpx/services/consumer.py
@@ -1,39 +1,39 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-import uvicorn
-from fastapi import FastAPI
-import httpx
-
-async_client = httpx.AsyncClient()
-client = httpx.Client()
-app = FastAPI()
-
-
[email protected]('/users')
-async def application():
- try:
- await async_client.post('http://provider:9091/users')
- res = client.post('http://provider:9091/users')
-
- return res.json()
- except Exception: # noqa
- return {'message': 'Error'}
-
-
-if __name__ == '__main__':
- uvicorn.run(app, host='0.0.0.0', port=9090)
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import uvicorn
+from fastapi import FastAPI
+import httpx
+
+async_client = httpx.AsyncClient()
+client = httpx.Client()
+app = FastAPI()
+
+
[email protected]('/users')
+async def application():
+ try:
+ await async_client.post('http://provider:9091/users', timeout=10.0)
+ res = client.post('http://provider:9091/users', timeout=10.0)
+
+ return res.json()
+ except Exception: # noqa
+ return {'message': 'Error'}
+
+
+if __name__ == '__main__':
+ uvicorn.run(app, host='0.0.0.0', port=9090)