Add barriers to fix flaky test_graph_for_py_nested_call and (#30624)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30624
These tests were flaky since we would end up calling the 'verify'
methods before some of the RPCs were done. The `check_rpc_done` function might
not guarantee this since set_rpc_done sets an appropriate flag in python which
causes `check_rpc_done` to pass. Although, there are a few steps after that
like attaching the send functions for the response of the RPC that might not
have executed by then.
ghstack-source-id: 94781954
Test Plan: Run the tests 100 times.
Reviewed By: zhaojuanmao
Differential Revision: D18768786
fbshipit-source-id: a14c3f4b27de14fe5ecc6e90854dc52652f769b8