Skip to content

Commit

Permalink
Set timeout and update fastApi
Browse files Browse the repository at this point in the history
  • Loading branch information
vgkoles committed Jun 18, 2024
1 parent 571fc28 commit 9260ddd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ async def get_status_for_url(item):
data = await fetch_data(query=query, values={'item': decoded_item })
return data

# Endpoint to retrieve URLs that that timed out. Timeout is set to 5 seconds currently
@app.get('/Timeout_URLs', response_model=List[StatusResponse])
async def get_timeout_urls():
query = """
SELECT DISTINCT *
FROM linkchecker_output
WHERE valid LIKE '%ReadTimeout%' OR valid LIKE '%ConnectTimeout%'
"""
data = await fetch_data(query=query)
return data

# Start the application
@app.on_event('startup')
async def startup():
Expand Down
5 changes: 3 additions & 2 deletions src/linkchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
base = os.environ.get("OGCAPI_URL") or "https://demo.pycsw.org/gisdata"
collection = os.environ.get("OGCAPI_COLLECTION") or "metadata:main"

# Remove comment'
catalogue_json_url = base + "collections/" + collection + "/items?f=json"
# format catalogue path with f-string
catalogue_json_url= f"{base}/collections/{collection}/items?f=json"

def setup_database():
# Connect to the database
Expand Down Expand Up @@ -112,6 +112,7 @@ def run_linkchecker(urls):
"--verbose",
"--check-extern",
"--recursion-level=1",
"--timeout=5",
"--output=csv",
url + "?f=html"
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down

0 comments on commit 9260ddd

Please sign in to comment.