Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/flask_consumer_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

@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()


Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/base/consumer/flask_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/plugin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ def validate(self, expected_file_name=None):
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)

if response.status_code != 200:
# heuristically retry once
time.sleep(10)
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)

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))

Expand Down
78 changes: 39 additions & 39 deletions tests/plugin/http/sw_httpx/services/consumer.py
Original file line number Diff line number Diff line change
@@ -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()
@app.post('/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()


@app.post('/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)
Loading