Esempio 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*."
Esempio 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."
Esempio 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*."
Esempio 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*."
Esempio 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*."
Esempio 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."
Esempio 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}'."
Esempio n. 8
0
 def globalize_instance(self, obj) -> None:
     _Globalize.condition(condition=obj)
Esempio n. 9
0
 def globalize_instance(self, obj) -> None:
     _Globalize.event(event=obj)
Esempio n. 10
0
 def globalize_instance(self, obj) -> None:
     _Globalize.semaphore(smp=obj)
Esempio n. 11
0
 def globalize_instance(self, obj) -> None:
     _Globalize.rlock(rlock=obj)
Esempio n. 12
0
 def globalize_instance(self, obj) -> None:
     _Globalize.bounded_semaphore(bsmp=obj)
Esempio n. 13
0
 def globalize_instance(self, obj) -> None:
     _Globalize.queue(name=self._name, queue=obj)