[rpc] don't crash callee when function does not exist on it, instead return Exception (#32726)
Summary:
Closes https://github.com/pytorch/pytorch/issues/27368.
Previously, if a function `'func` did not exist on worker A but existed in B, and the user ran `rpc.rpc_sync(A, func)`, A would crash with a segmentation fault since it is not able to find the function. B would eventually timeout since RPCs by default time out in 60s.
At the root this comes from an unhandled exception when trying to deserialize the `PythonUDF` to run.
This PR makes it so that we can recover from this error, and A reports back a `RemoteException` to B indicating that the function was not found. Now, A will no longer crash and B can handle the exception appropriately and with more information.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32726
Differential Revision: D19648825
Pulled By: rohan-varma
fbshipit-source-id: 53847f4bfb68187db41c61d69ddac13613e814b4