@@ -1771,18 +1771,18 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
1771
1771
assert int (response .http_request .headers .get ("x-stainless-retry-count" )) == failures_before_success
1772
1772
1773
1773
def test_get_platform (self ) -> None :
1774
- # Issue https://github.com/openai/openai-python/issues/1827 was caused
1775
- # asyncify leaving threads unterminated when used with nest_asyncio.
1774
+ # A previous implementation of asyncify could leave threads unterminated when
1775
+ # used with nest_asyncio.
1776
+ #
1776
1777
# Since nest_asyncio.apply() is global and cannot be un-applied, this
1777
1778
# test is run in a separate process to avoid affecting other tests.
1778
- test_code = dedent ("""\
1779
+ test_code = dedent ("""
1779
1780
import asyncio
1780
1781
import nest_asyncio
1781
-
1782
1782
import threading
1783
1783
1784
- from openai._base_client import get_platform
1785
1784
from openai._utils import asyncify
1785
+ from openai._base_client import get_platform
1786
1786
1787
1787
async def test_main() -> None:
1788
1788
result = await asyncify(get_platform)()
@@ -1795,17 +1795,12 @@ async def test_main() -> None:
1795
1795
""" )
1796
1796
with subprocess .Popen (
1797
1797
[sys .executable , "-c" , test_code ],
1798
- stdout = subprocess .PIPE ,
1799
- stderr = subprocess .PIPE ,
1800
1798
text = True ,
1801
1799
) as process :
1802
1800
try :
1803
1801
process .wait (2 )
1804
1802
if process .returncode :
1805
- print (process .stdout )
1806
- print (process .stderr )
1807
1803
raise AssertionError ("calling get_platform using asyncify resulted in a non-zero exit code" )
1808
1804
except subprocess .TimeoutExpired as e :
1809
1805
process .kill ()
1810
1806
raise AssertionError ("calling get_platform using asyncify resulted in a hung process" ) from e
1811
-
0 commit comments