Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
70769902
Unverified
Commit
70769902
authored
Aug 21, 2025
by
Biswa Panda
Committed by
GitHub
Aug 22, 2025
Browse files
fix: prevent crash looping hello world (#2625)
parent
9ab37d94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
4 deletions
+27
-4
examples/runtime/hello_world/client.py
examples/runtime/hello_world/client.py
+27
-4
No files found.
examples/runtime/hello_world/client.py
View file @
70769902
...
@@ -31,10 +31,33 @@ async def worker(runtime: DistributedRuntime):
...
@@ -31,10 +31,33 @@ async def worker(runtime: DistributedRuntime):
client
=
await
endpoint
.
client
()
client
=
await
endpoint
.
client
()
await
client
.
wait_for_instances
()
await
client
.
wait_for_instances
()
# Issue request and process the stream
idx
=
0
stream
=
await
client
.
generate
(
"world,sun,moon,star"
)
base_delay
=
0.1
# Start with 100ms
async
for
response
in
stream
:
max_delay
=
5.0
# Max 5 seconds
print
(
response
.
data
())
current_delay
=
base_delay
while
True
:
try
:
# Issue request and process the stream
idx
+=
1
stream
=
await
client
.
generate
(
f
"Query[
{
idx
}
] Hello world"
)
async
for
response
in
stream
:
print
(
response
.
data
())
# Reset backoff on successful iteration
current_delay
=
base_delay
# Sleep for 1 second
await
asyncio
.
sleep
(
1
)
except
asyncio
.
CancelledError
:
# Re-raise for graceful shutdown
raise
except
Exception
as
e
:
# Log the exception with context
print
(
f
"Error in worker iteration
{
idx
}
:
{
type
(
e
).
__name__
}
:
{
e
}
"
)
# Perform exponential backoff
print
(
f
"Retrying after
{
current_delay
:.
2
f
}
seconds..."
)
await
asyncio
.
sleep
(
current_delay
)
# Double the delay for next time, up to max_delay
current_delay
=
min
(
current_delay
*
2
,
max_delay
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment