Beispiel #1
0
def test_tagged_constructor():
    @tagged(TestTag.ALICE)
    def f():
        pass

    proc = Process(Simulator(), f, None)
    assert proc.has_tag(TestTag.ALICE)
Beispiel #2
0
def test_probing_current_process():
    def proc():
        assert Process.current_exists()

    assert not Process.current_exists()
    sim = Simulator()
    sim.add(proc)
    sim.run()
    assert not Process.current_exists()
Beispiel #3
0
    def traverse(self) -> None:
        # Invoked by crossing passengers in order to get through their luggage and body scan.
        me = local.name
        if self._num_standing == 0:
            period_empty = now() - self._moment_empty
            self._time_empty += period_empty
            debug(f"Belt {self.num} -- Empty period: {period_empty:.1f} -- Time empty: {self.time_empty:.1f}")
        self._num_standing += 1
        info(f"Traveler {me} entering belt {self.num}; now {self.num_standing} travelers here")

        # Prepare for check.
        advance(next(traveler_preparation))

        # Wait for an agent to beckon.
        info(f"Traveler {me} (belt {self.num}) prepared and ready for processing")
        self._traveler_ready.turn_on()
        self._travelers_waiting.join()

        with local.agent.using():  # Make agent busy with me.
            # Administer scan or patdown.
            agent_name = Process.current().local.agent_name
            processing_type = next(traveler_processing_type)
            info(f"Traveler {me} processed by agent {agent_name}: {processing_type}")
            advance(next(traveler_processing_time[processing_type]))

        info(f"Traveler {me} (belt {self.num}) buckling back up")
        advance(next(traveler_preparation))

        self._num_standing -= 1
        if self._num_standing == 0:
            debug(f"Belt {self.num} now empty")
            self._moment_empty = now()
Beispiel #4
0
 def proc():
     assert Process.current_exists()
Beispiel #5
0
 def proc():
     assert isinstance(Process.current(), Process)
Beispiel #6
0
 def last_proc():
     nonlocal when_last
     when_last = now()
     assert Process.current().has_tag(TestTag.ALICE)
     assert Process.current().has_tag(TestTag.BOB)
def tag_checker(tag_set):
    global flag, short_tag_set
    flag = 1
    assert tag_set == Process.current()._tag_set
 def tag_receiver():
     assert not Process.current().has_tag(IntegTestTag.CANADA)
Beispiel #9
0
 def proc():
     nonlocal proc_interrupter
     local.name = "main"
     proc_interrupter = add(interrupter, Process.current())
     advance(10)
     advance(10)
Beispiel #10
0
 def proc():
     nonlocal proc_resumer
     local.name = "i-am-process"
     advance(10)
     proc_resumer = add(resumer, Process.current())
     pause()