Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __call__(self):
# List in which we store all ongoing communications
pending_comms = []
# Vector of the used mailboxes
mboxes = [Mailbox.by_name("receiver-{:d}".format(i))
for i in range(0, self.receivers_count)]
# Start dispatching all messages to receivers, in a round robin fashion
for i in range(0, self.messages_count):
content = "Message {:d}".format(i)
mbox = mboxes[i % self.receivers_count]
this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))
# Create a communication representing the ongoing communication, and store it in pending_comms
comm = mbox.put_async(content, self.msg_size)
pending_comms.append(comm)
# Start sending messages to let the workers know that they should stop
for i in range(0, self.receivers_count):
mbox = mboxes[i]
def forwarder(*args):
"""Our second class of actors is also a function"""
if len(args) < 2:
raise AssertionError(
"Actor forwarder requires 2 parameters, but got only {:d}".format(len(args)))
mb_in = Mailbox.by_name(args[0])
mb_out = Mailbox.by_name(args[1])
msg = mb_in.get()
this_actor.info("Forward '{:s}'.".format(msg))
mb_out.put(msg, len(msg))
def __call__(self):
# List in which we store all ongoing communications
pending_comms = []
# Vector of the used mailboxes
mboxes = [Mailbox.by_name("receiver-{:d}".format(i)) for i in range(0, self.receivers_count)]
# Start dispatching all messages to receivers, in a round robin fashion
for i in range(0, self.messages_count):
content = "Message {:d}".format(i)
mbox = mboxes[i % self.receivers_count]
this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))
# Create a communication representing the ongoing communication, and store it in pending_comms
comm = mbox.put_async(content, self.msg_size)
pending_comms.append(comm)
# Start sending messages to let the workers know that they should stop
for i in range(0, self.receivers_count):
mbox = mboxes[i]
this_actor.info("Send 'finalize' to '{:s}'".format(str(mbox)))
def __call__(self):
this_actor.info("Hello s4u, I have something to send")
mailbox = Mailbox.by_name(self.mbox)
mailbox.put(self.msg, len(self.msg))
this_actor.info("I'm done. See you.")
def __call__(self):
# List in which we store all ongoing communications
pending_comms = []
# Vector of the used mailboxes
mboxes = [Mailbox.by_name("receiver-{:d}".format(i))
for i in range(0, self.receivers_count)]
# Start dispatching all messages to receivers, in a round robin fashion
for i in range(0, self.messages_count):
content = "Message {:d}".format(i)
mbox = mboxes[i % self.receivers_count]
this_actor.info("Send '{:s}' to '{:s}'".format(content, str(mbox)))
# Create a communication representing the ongoing communication, and store it in pending_comms
comm = mbox.put_async(content, self.msg_size)
pending_comms.append(comm)
# Start sending messages to let the workers know that they should stop
for i in range(0, self.receivers_count):
mbox = mboxes[i]