Skip to content

Commit

Permalink
improve timeout handling and fix timeout issue with place publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
treeben77 committed Jan 1, 2025
1 parent d849db7 commit 8ca72a8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2024 treeben77
Copyright (c) 2022-2025 treeben77

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions rblxopencloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

# Copyright (c) 2022-2024 treeben77
# Copyright (c) 2022-2025 treeben77

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,7 +24,7 @@

import requests

VERSION: str = "2.1.4"
VERSION: str = "2.1.5"
VERSION_INFO: Literal["alpha", "beta", "final"] = "final"

user_agent: str = (
Expand Down
3 changes: 2 additions & 1 deletion rblxopencloud/experience.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

# Copyright (c) 2022-2024 treeben77
# Copyright (c) 2022-2025 treeben77

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -484,6 +484,7 @@ def upload_place_file(
headers={"content-type": "application/octet-stream"},
params={"versionType": "Published" if publish else "Saved"},
data=file.read(),
timeout=180,
)

return data["versionNumber"]
Expand Down
8 changes: 6 additions & 2 deletions rblxopencloud/http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

# Copyright (c) 2022-2024 treeben77
# Copyright (c) 2022-2025 treeben77

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -84,6 +84,8 @@ def send_request(
python object to be sent in the request.
data (Union[bytes], dict): The data to send with the request. *Can \
not be used with `json` parameter.*
timeout (float): The number of seconds until the request times out. \
Defaults to 15 seconds. Set to `None` for no timeout (not recommended).
Returns:
A tuple with the first value being the status code, the second value \
Expand Down Expand Up @@ -121,12 +123,14 @@ def send_request(
if path.startswith("/"):
path = f"cloud/v2{path}"

if not kwargs.get("timeout"):
kwargs["timeout"] = 15

response = http_session.request(
method,
f"https://apis.roblox.com/{path}",
headers=headers,
**kwargs,
timeout=10,
)

if "application/json" in response.headers.get("Content-Type", ""):
Expand Down
4 changes: 2 additions & 2 deletions rblxopencloudasync/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

# Copyright (c) 2022-2024 treeben77
# Copyright (c) 2022-2025 treeben77

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,7 +24,7 @@

import aiohttp

VERSION: str = "2.1.4"
VERSION: str = "2.1.5"
VERSION_INFO: Literal["alpha", "beta", "final"] = "final"

user_agent: str = (
Expand Down
3 changes: 2 additions & 1 deletion rblxopencloudasync/experience.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

# Copyright (c) 2022-2024 treeben77
# Copyright (c) 2022-2025 treeben77

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -484,6 +484,7 @@ async def upload_place_file(
headers={"content-type": "application/octet-stream"},
params={"versionType": "Published" if publish else "Saved"},
data=file.read(),
timeout=180,
)

return data["versionNumber"]
Expand Down
8 changes: 6 additions & 2 deletions rblxopencloudasync/http.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

# Copyright (c) 2022-2024 treeben77
# Copyright (c) 2022-2025 treeben77

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -86,6 +86,8 @@ async def send_request(
python object to be sent in the request.
data (Union[bytes], dict): The data to send with the request. *Can \
not be used with `json` parameter.*
timeout (float): The number of seconds until the request times out. \
Defaults to 15 seconds. Set to `None` for no timeout (not recommended).
Returns:
A tuple with the first value being the status code, the second value \
Expand Down Expand Up @@ -135,12 +137,14 @@ async def send_request(
if type(v) == bool:
kwargs["params"][k] = str(v).lower()

if not kwargs.get("timeout"):
kwargs["timeout"] = 15

response = await http_session.request(
method,
f"https://apis.roblox.com/{path}",
headers=headers,
**kwargs,
timeout=10,
)

if "application/json" in response.headers.get("Content-Type", ""):
Expand Down

0 comments on commit 8ca72a8

Please sign in to comment.