Пример #1
0
def test_monitor():
    import time
    a = bzoinq.Bzoinq()
    a.create_task("First task")
    b = bzoinq.Monitor(a)
    b.start()
    time.sleep(5)
    b.stop()
Пример #2
0
def test_monitor_again():
    import time
    a = bzoinq.Bzoinq()
    b = bzoinq.Monitor(a)
    b.start()
    a.create_task("Task to test the Monitor")
    time.sleep(3)
    a.create_task("Second task to test the Monitor")
    time.sleep(3)
    b.stop()
Пример #3
0
def testfunction():
    def printme():
        print("function run ok")

    import time
    a = bzoinq.Bzoinq()
    b = bzoinq.Monitor(a)
    b.start()
    a.create_task("Testing a function", function=printme)
    time.sleep(2)
    b.stop()
Пример #4
0
def test_two_tasks():
    import datetime
    import time
    current_time = datetime.datetime.now()
    time_in_10 = current_time + datetime.timedelta(seconds=10)
    time_in_5 = current_time + datetime.timedelta(seconds=5)
    a = bzoinq.Bzoinq()
    a.create_task("10 seconds task", time_in_10)
    a.create_task("5 seconds task", time_in_5)
    b = bzoinq.Monitor(a)
    b.start()
    time.sleep(15)
    b.stop()
Пример #5
0
def test_sound_and_task():
    a = bzoinq.Bzoinq()
    a.create_task()
    # test that the first id is 1
    assert a.task_id == 1