A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactorize the sthread interception of functions
[simgrid.git]
/
examples
/
python
/
comm-failure
/
comm-failure.py
diff --git
a/examples/python/comm-failure/comm-failure.py
b/examples/python/comm-failure/comm-failure.py
index 91ec73d3b5e39e0f1735d45e6269d5f16204c91b..02cd7013777ce23d6d14fac2e027e69982b74f70 100644
(file)
--- a/
examples/python/comm-failure/comm-failure.py
+++ b/
examples/python/comm-failure/comm-failure.py
@@
-5,7
+5,7
@@
import sys
import sys
-from simgrid import Engine, Actor, Comm, NetZone, Link, LinkInRoute, Mailbox, this_actor, NetworkFailureException
+from simgrid import Engine, Actor,
ActivitySet,
Comm, NetZone, Link, LinkInRoute, Mailbox, this_actor, NetworkFailureException
def sender(mailbox1_name: str, mailbox2_name: str) -> None:
def sender(mailbox1_name: str, mailbox2_name: str) -> None:
@@
-18,14
+18,14
@@
def sender(mailbox1_name: str, mailbox2_name: str) -> None:
this_actor.info(f"Initiating asynchronous send to {mailbox2.name}")
comm2: Comm = mailbox2.put_async(666, 2)
this_actor.info(f"Initiating asynchronous send to {mailbox2.name}")
comm2: Comm = mailbox2.put_async(666, 2)
- this_actor.info(
f
"Calling wait_any..")
- pending_comms =
[comm1, comm2]
+ this_actor.info("Calling wait_any..")
+ pending_comms =
ActivitySet([comm1, comm2])
try:
try:
-
index = Comm.wait_any([comm1, comm2]
)
- this_actor.info(f"Wait any returned
index {index} (comm to {pending_comms[index]
.mailbox.name})")
+
comm = pending_comms.wait_any(
)
+ this_actor.info(f"Wait any returned
a comm to {comm
.mailbox.name})")
except NetworkFailureException:
except NetworkFailureException:
- this_actor.info(
f
"Sender has experienced a network failure exception, so it knows that something went wrong")
- this_actor.info(
f
"Now it needs to figure out which of the two comms failed by looking at their state:")
+ this_actor.info("Sender has experienced a network failure exception, so it knows that something went wrong")
+ this_actor.info("Now it needs to figure out which of the two comms failed by looking at their state:")
this_actor.info(f" Comm to {comm1.mailbox.name} has state: {comm1.state_str}")
this_actor.info(f" Comm to {comm2.mailbox.name} has state: {comm2.state_str}")
this_actor.info(f" Comm to {comm1.mailbox.name} has state: {comm1.state_str}")
this_actor.info(f" Comm to {comm2.mailbox.name} has state: {comm2.state_str}")
@@
-36,9
+36,8
@@
def sender(mailbox1_name: str, mailbox2_name: str) -> None:
this_actor.info(f"Waiting on a FAILED comm raises an exception: '{err}'")
this_actor.info("Wait for remaining comm, just to be nice")
this_actor.info(f"Waiting on a FAILED comm raises an exception: '{err}'")
this_actor.info("Wait for remaining comm, just to be nice")
- pending_comms.pop(0)
try:
try:
-
Comm.wait_any(pending_comms
)
+
pending_comms.wait_all(
)
except Exception as e:
this_actor.warning(str(e))
except Exception as e:
this_actor.warning(str(e))
@@
-66,11
+65,11
@@
def main():
host2 = zone.create_host("Host2", "1f")
host3 = zone.create_host("Host3", "1f")
host2 = zone.create_host("Host2", "1f")
host3 = zone.create_host("Host3", "1f")
- link_to_2 =
LinkInRoute(zone.create_link("link_to_2", "1bps").seal()
)
- link_to_3 =
LinkInRoute(zone.create_link("link_to_3", "1bps").seal()
)
+ link_to_2 =
zone.create_link("link_to_2", "1bps").seal(
)
+ link_to_3 =
zone.create_link("link_to_3", "1bps").seal(
)
- zone.add_route(host1
.netpoint, host2.netpoint, None, None, [link_to_2], False
)
- zone.add_route(host1
.netpoint, host3.netpoint, None, None, [link_to_3], False
)
+ zone.add_route(host1
, host2, [link_to_2]
)
+ zone.add_route(host1
, host3, [link_to_3]
)
zone.seal()
Actor.create("Sender", host1, sender, "mailbox2", "mailbox3")
zone.seal()
Actor.create("Sender", host1, sender, "mailbox2", "mailbox3")