-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
python/tests/server/fixtures/async_setup_uses_same_loop_as_predict.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import asyncio | ||
|
||
|
||
class Predictor: | ||
async def setup(self) -> None: | ||
self.loop = asyncio.get_running_loop() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Predictor: | ||
async def download(self) -> None: | ||
print("download complete!") | ||
|
||
async def setup(self) -> None: | ||
print("setup starting...") | ||
await self.download() | ||
print("setup complete!") | ||
|
||
async def predict(self) -> str: | ||
print("running prediction") | ||
return "output" |
9 changes: 9 additions & 0 deletions
9
python/tests/server/fixtures/setup_async_with_sync_predict.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Predictor: | ||
async def download(self) -> None: | ||
print("setup used asyncio.run! it's not very effective...") | ||
|
||
async def setup(self) -> None: | ||
await self.download() | ||
|
||
def predict(self) -> str: | ||
return "output" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters