コード例 #1
0
    def test_task_is_scheduled(self):
        task = tracemalloctext.Task(noop)
        task.set_delay(60)

        task.schedule()
        self.assertTrue(task.is_scheduled())

        # schedule twice should not fail
        task.schedule()

        task.cancel()
        self.assertFalse(task.is_scheduled())

        # second cancel() should not fail
        task.cancel()

        # cannot schedule if the tracemalloc module is disabled
        tracemalloc.disable()
        with self.assertRaises(RuntimeError) as cm:
            task.schedule()
        self.assertEqual(str(cm.exception),
                         "the tracemalloc module must be enabled "
                         "to schedule a task")
コード例 #2
0
 def tearDown(self):
     tracemalloc.disable()
     gc.set_debug(0)
コード例 #3
0
def clear_stats():
    tracemalloc.disable()
    tracemalloc.enable()
コード例 #4
0
 def tearDown(self):
     tracemalloc.disable()
     gc.set_debug(0)
コード例 #5
0
def clear_stats():
    tracemalloc.disable()
    tracemalloc.enable()
コード例 #6
0
 def tearDown(self):
     tracemalloctext.cancel_tasks()
     tracemalloc.disable()
     tracemalloc.clear_filters()