Skip to content

Commit b6f4bb0

Browse files
Mike Ruberryfacebook-github-bot
authored andcommitted
Revert D23236088: [pytorch][PR] [caffe2] adds Cancel to SafeDequeueBlobsOp and SafeEnqueueBlobsOp
Test Plan: revert-hammer Differential Revision: D23236088 (0ccc38b) Original commit changeset: daa90d9ee324 fbshipit-source-id: 933c7deab177250075683a9bea143ac37f16a598
1 parent e18a221 commit b6f4bb0

File tree

2 files changed

+1
-69
lines changed

2 files changed

+1
-69
lines changed

caffe2/python/hypothesis_test.py

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from hypothesis import assume, given, settings, HealthCheck
1111
import hypothesis.strategies as st
1212
import unittest
13-
import threading
13+
import os
1414

1515
from caffe2.python import core, workspace, tt_core, dyndep
1616
import caffe2.python.hypothesis_test_util as hu
@@ -2697,61 +2697,5 @@ def histogram(X):
26972697

26982698

26992699

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-
27562700
if __name__ == "__main__":
27572701
unittest.main()

caffe2/queue/queue_ops.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ class SafeEnqueueBlobsOp final : public Operator<Context> {
113113
1, !status, Output(size)->template mutable_data<bool>(), &context_);
114114
return true;
115115
}
116-
117-
void Cancel() override {
118-
auto queue = Operator<Context>::Inputs()[0]
119-
->template Get<std::shared_ptr<BlobsQueue>>();
120-
queue->close();
121-
}
122116
};
123117

124118
template <typename Context>
@@ -198,12 +192,6 @@ class SafeDequeueBlobsOp final : public Operator<Context> {
198192
return true;
199193
}
200194

201-
void Cancel() override {
202-
auto queue = Operator<Context>::Inputs()[0]
203-
->template Get<std::shared_ptr<BlobsQueue>>();
204-
queue->close();
205-
}
206-
207195
private:
208196
int numRecords_;
209197
std::vector<Blob> blobs_;

0 commit comments

Comments
 (0)