Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Makes the fastapi async example more robust #211

Merged
merged 1 commit into from
Oct 27, 2022
Merged

Conversation

skrawcz
Copy link
Collaborator

@skrawcz skrawcz commented Oct 17, 2022

When you use /docs to create the request, it does not pass in an empty dict, so making sure the path does not break.

Changes

  • adds try/except to async example
  • adds way to run fastapi by just running fastapi_example.py

Testing

  1. Works locally

Notes

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Python - local testing

  • python 3.9

When you use `/docs` to create the request, it does
not pass in an empty dict, so making sure the path
does not break.
return await request.json()
except json.JSONDecodeError as e:
logger.warning(f"Unable to get JSON from request. Error is:\n{e}")
return {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shouldn't this be a 4XX?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the json body is empty. So it's not a bad request.

@skrawcz skrawcz merged commit e3501ef into main Oct 27, 2022
@skrawcz skrawcz deleted the adjust_asyncio_example branch October 27, 2022 17:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants