Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
34c575bc
Commit
34c575bc
authored
Sep 17, 2022
by
Jonas Kaufmann
Committed by
Antoine Kaufmann
Sep 17, 2022
Browse files
implement Ctrl+C handling for DistributedSimpleRuntime
parent
5923f91a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
experiments/simbricks/runtime/distributed.py
experiments/simbricks/runtime/distributed.py
+20
-10
No files found.
experiments/simbricks/runtime/distributed.py
View file @
34c575bc
...
...
@@ -40,6 +40,8 @@ class DistributedSimpleRuntime(Runtime):
self
.
verbose
=
verbose
self
.
executors
=
executors
self
.
_running
:
asyncio
.
Task
def
add_run
(
self
,
run
:
Run
):
if
not
isinstance
(
run
.
experiment
,
DistributedExperiment
):
raise
RuntimeError
(
'Only distributed experiments supported'
)
...
...
@@ -54,10 +56,17 @@ class DistributedSimpleRuntime(Runtime):
run
.
env
,
self
.
verbose
)
for
executor
in
self
.
executors
:
await
run
.
prep_dirs
(
executor
)
await
runner
.
prepare
()
run
.
output
=
await
runner
.
run
()
try
:
for
executor
in
self
.
executors
:
await
run
.
prep_dirs
(
executor
)
await
runner
.
prepare
()
except
asyncio
.
CancelledError
:
# it is safe to just exit here because we are not running any
# simulators yet
return
run
.
output
=
await
runner
.
run
()
# already handles CancelledError
self
.
complete
.
append
(
run
)
pathlib
.
Path
(
run
.
outpath
).
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
...
...
@@ -66,15 +75,16 @@ class DistributedSimpleRuntime(Runtime):
async
def
start
(
self
):
for
run
in
self
.
runnable
:
asyncio
.
run
(
self
.
do_run
(
run
))
if
self
.
_interrupted
:
return
self
.
_running
=
asyncio
.
create_task
(
self
.
do_run
(
run
))
await
self
.
_running
def
interrupt
(
self
):
# TODO implement this
super
().
interrupt
()
print
(
'Ctrl+C handling for DistributedRuntime not yet implemented. '
'You need to kill the processes manually.'
)
if
self
.
_running
:
self
.
_running
.
cancel
()
def
auto_dist
(
...
...
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