-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translate RPC timeout error message. (#1313)
- Loading branch information
1 parent
a5023a8
commit bbba46b
Showing
5 changed files
with
113 additions
and
6 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
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,35 @@ | ||
import asyncio | ||
import time | ||
|
||
import truss_chains as chains | ||
|
||
|
||
class Dependency(chains.ChainletBase): | ||
async def run_remote(self) -> bool: | ||
await asyncio.sleep(1) | ||
return True | ||
|
||
|
||
class DependencySync(chains.ChainletBase): | ||
def run_remote(self) -> bool: | ||
time.sleep(1) | ||
return True | ||
|
||
|
||
@chains.mark_entrypoint # ("My Chain Name") | ||
class TimeoutChain(chains.ChainletBase): | ||
def __init__( | ||
self, | ||
dep=chains.depends(Dependency, timeout_sec=0.5), | ||
dep_sync=chains.depends(DependencySync, timeout_sec=0.5), | ||
): | ||
self._dep = dep | ||
self._dep_sync = dep_sync | ||
|
||
async def run_remote(self, use_sync: bool) -> None: | ||
if use_sync: | ||
result = self._dep_sync.run_remote() | ||
print(result) | ||
else: | ||
result = await self._dep.run_remote() | ||
print(result) |
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
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
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