Skip to content

Commit

Permalink
add http_client changes to fernignore
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko committed Sep 10, 2024
1 parent 42e8681 commit 86b3a55
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Specify files that shouldn't be modified by Fern

src/gooey/core/http_client.py
23 changes: 21 additions & 2 deletions src/gooey/core/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
import email.utils
import json
import json as json_module
import re
import time
import typing
Expand Down Expand Up @@ -188,6 +188,8 @@ def request(
else self.base_timeout
)

if not json and isinstance(data, typing.Mapping):
data = {"json": json_module.dumps(data)}
json_body, data_body = get_request_body(json=json, data=data, request_options=request_options, omit=omit)

response = self.httpx_client.request(
Expand Down Expand Up @@ -244,7 +246,24 @@ def request(
omit=omit,
)

return response
location = response.headers.get("location")
if not location:
return response

while True:
response = self.request(location, method="get")
if not response.is_success:
print(response)
print("body", response.json())
return response
else:
body = response.json()
if body.get("status") in ["starting", "running"]:
continue
else: # failed, completed, or something not in the spec
print(response)
print("body", body)
return response

@contextmanager
def stream(
Expand Down

0 comments on commit 86b3a55

Please sign in to comment.