Exemplo n.º 1
0
    def test_semaphore_with_normal_value(self):
        from multiprocessing.synchronize import Semaphore as synchronize_Semaphore
        from multiprocessing import Semaphore

        Globalize.semaphore(smp=Semaphore())
        from multirunnable.api.manage import Running_Semaphore
        assert isinstance(
            Running_Semaphore, synchronize_Semaphore
        ) is True, "It should save instance to the target global variable *Running_Semaphore*."
Exemplo n.º 2
0
 def test_bounded_semaphore_with_none_value(self):
     try:
         Globalize.bounded_semaphore(bsmp=None)
     except GlobalizeObjectError as e:
         assert "Cannot globalize target object because it is None object" in str(
             e
         ), "It should raise an exception about target object could not be a None object."
     else:
         assert False, "It should raise an exception if the value is None."
Exemplo n.º 3
0
    def test_condition_with_normal_value(self):
        from multiprocessing.synchronize import Condition as synchronize_Condition
        from multiprocessing import Condition

        Globalize.condition(condition=Condition())
        from multirunnable.api.manage import Running_Condition
        assert isinstance(
            Running_Condition, synchronize_Condition
        ) is True, "It should save instance to the target global variable *Running_Condition*."
Exemplo n.º 4
0
    def test_rlock_with_normal_value(self):
        from multiprocessing.synchronize import RLock as synchronize_RLock
        from multiprocessing import RLock

        Globalize.rlock(rlock=RLock())
        from multirunnable.api.manage import Running_RLock
        assert isinstance(
            Running_RLock, synchronize_RLock
        ) is True, "It should save instance to the target global variable *Running_RLock*."
Exemplo n.º 5
0
    def test_event_with_normal_value(self):
        from multiprocessing.synchronize import Event as synchronize_Event
        from multiprocessing import Event

        Globalize.event(event=Event())
        from multirunnable.api.manage import Running_Event
        assert isinstance(
            Running_Event, synchronize_Event
        ) is True, "It should save instance to the target global variable *Running_Event*."
Exemplo n.º 6
0
    def test_queue_with_none_value(self):
        _test_name = "test_name"

        try:
            Globalize.queue(name=_test_name, queue=None)
        except GlobalizeObjectError as e:
            assert "Cannot globalize target object because it is None object" in str(
                e
            ), "It should raise an exception about target object could not be a None object."
        else:
            assert False, "It should raise an exception if the value is None."
Exemplo n.º 7
0
    def test_queue_with_normal_value(self):
        _test_name = "test_name"
        _test_value = "test_value"

        try:
            Globalize.queue(name=_test_name, queue=None)
        except GlobalizeObjectError as e:
            assert "Cannot globalize target object because it is None object" in str(
                e
            ), "It should raise an exception about target object could not be a None object."
        else:
            assert False, "It should raise an exception if the value is None."

        Globalize.queue(name=_test_name, queue=_test_value)
        from multirunnable.api.manage import Running_Queue
        assert _test_name in Running_Queue.keys(
        ), f"The testing name '{_test_name}' should be in the keys."
        assert _test_value == Running_Queue[
            _test_name], f"The value should be the same as we set '{_test_value}'."
Exemplo n.º 8
0
 def globalize_instance(self, obj) -> None:
     _Globalize.condition(condition=obj)
Exemplo n.º 9
0
 def globalize_instance(self, obj) -> None:
     _Globalize.event(event=obj)
Exemplo n.º 10
0
 def globalize_instance(self, obj) -> None:
     _Globalize.semaphore(smp=obj)
Exemplo n.º 11
0
 def globalize_instance(self, obj) -> None:
     _Globalize.rlock(rlock=obj)
Exemplo n.º 12
0
 def globalize_instance(self, obj) -> None:
     _Globalize.bounded_semaphore(bsmp=obj)
Exemplo n.º 13
0
 def globalize_instance(self, obj) -> None:
     _Globalize.queue(name=self._name, queue=obj)