Skip to content

Commit

Permalink
Upped ver, added sleeping to some funcs
Browse files Browse the repository at this point in the history
Have been running into inconsistent 502 responses from EZOffice API. Most commonly on the paginated funcs pulling lots of info. So added small amounts of sleeping in those funcs in case the issue was running into rate limiting issues.

I.E.:
- Assets
- Locations
- Members
  • Loading branch information
JMaynor committed Aug 26, 2024
1 parent be9d70e commit b4e124c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions ezoff/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import os
import time

import requests

Expand Down Expand Up @@ -75,6 +76,10 @@ def get_all_assets() -> list[dict]:

page += 1

# Potentially running into rate limiting issues with this endpoint
# Sleep for a second to avoid this
time.sleep(1)

return all_assets


Expand Down Expand Up @@ -144,6 +149,10 @@ def get_filtered_assets(filter: dict) -> list[dict]:

page += 1

# Potentially running into rate limiting issues with this endpoint
# Sleep for a second to avoid this
time.sleep(1)

return all_assets


Expand Down
5 changes: 5 additions & 0 deletions ezoff/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import os
import time
from typing import Optional

import requests
Expand Down Expand Up @@ -77,6 +78,10 @@ def get_locations(filter: Optional[dict]) -> list[dict]:

page += 1

# Potentially running into rate limiting issues with this endpoint
# Sleep for a second to avoid this
time.sleep(1)

return all_locations


Expand Down
5 changes: 5 additions & 0 deletions ezoff/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import os
import time
from typing import Optional

import requests
Expand Down Expand Up @@ -82,6 +83,10 @@ def get_members(filter: Optional[dict]) -> list[dict]:

page += 1

# Potentially running into rate limiting issues with this endpoint
# Sleep for a second to avoid this
time.sleep(1)

return all_members


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="ezoff",
version="0.1.2",
version="0.1.3",
description="Python package that acts as a wrapper for the EZOffice API.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit b4e124c

Please sign in to comment.