|
10 | 10 | from hypothesis import assume, given, settings, HealthCheck |
11 | 11 | import hypothesis.strategies as st |
12 | 12 | import unittest |
13 | | -import threading |
| 13 | +import os |
14 | 14 |
|
15 | 15 | from caffe2.python import core, workspace, tt_core, dyndep |
16 | 16 | import caffe2.python.hypothesis_test_util as hu |
@@ -2697,61 +2697,5 @@ def histogram(X): |
2697 | 2697 |
|
2698 | 2698 |
|
2699 | 2699 |
|
2700 | | - @settings(max_examples=1, deadline=None) |
2701 | | - @given( |
2702 | | - queue_capacity=st.integers(2, 2), |
2703 | | - time_sleep=st.integers(5, 10), |
2704 | | - num_blobs_to_equeue=st.integers(1, 1), |
2705 | | - num_blobs_to_dequeue=st.integers(2, 2), |
2706 | | - ) |
2707 | | - def test_safe_dequeue_blob__raises_exception_when_hang( |
2708 | | - self, |
2709 | | - queue_capacity, |
2710 | | - time_sleep, |
2711 | | - num_blobs_to_equeue, |
2712 | | - num_blobs_to_dequeue, |
2713 | | - ): |
2714 | | - r""" |
2715 | | - Tests SafeDequeueBlobsOp being cancellable. |
2716 | | -
|
2717 | | - Create a queue with the number of BlobsQueue less than the number |
2718 | | - SafeDequeueBlobs to cause the hanging behavior when running the Net. |
2719 | | -
|
2720 | | - Then call cancel from the previous sleeping thread to ensure exception |
2721 | | - is raised. |
2722 | | - """ |
2723 | | - |
2724 | | - def _net_instance_cancel(net_instance): |
2725 | | - time.sleep(time_sleep) |
2726 | | - net_instance.cancel() |
2727 | | - |
2728 | | - init_net = core.Net("init_net") |
2729 | | - init_net.Proto().type = "deferrable_async_scheduling" |
2730 | | - |
2731 | | - queue = init_net.CreateBlobsQueue( |
2732 | | - [], |
2733 | | - "queue_name", |
2734 | | - capacity=queue_capacity, |
2735 | | - num_blobs=num_blobs_to_equeue, |
2736 | | - ) |
2737 | | - |
2738 | | - ws = workspace.Workspace() |
2739 | | - ws.create_net(init_net).run() |
2740 | | - |
2741 | | - net = core.Net("net") |
2742 | | - net.Proto().type = "deferrable_async_scheduling" |
2743 | | - |
2744 | | - blobs = net.SafeDequeueBlobs([queue], num_blobs_to_dequeue) |
2745 | | - |
2746 | | - net_instance = ws.create_net(net) |
2747 | | - |
2748 | | - t = threading.Thread(target=_net_instance_cancel, args=[net_instance]) |
2749 | | - t.start() |
2750 | | - |
2751 | | - with self.assertRaises(Exception): |
2752 | | - net_instance.run() |
2753 | | - t.join() |
2754 | | - |
2755 | | - |
2756 | 2700 | if __name__ == "__main__": |
2757 | 2701 | unittest.main() |
0 commit comments