title: The results is different when placing torch.distributed.rpc.rpc_aync at a different .py file
body: <p>I want to execute a function at the worker side and return the results to the master. However, I find that the results is different when placing rpc_async at a different .py file</p>
  <h4>Method 1</h4>
  <p>master.py:</p>
  <pre class="lang-py prettyprint-override"><code>
  import os
  import torch
  import torch.distributed.rpc as rpc
  from torch.distributed.rpc import RRef
  from test import sub_fun
  
  os.environ['MASTER_ADDR'] = '10.5.26.19'
  os.environ['MASTER_PORT'] = '5677'
  
  rpc.init_rpc(&quot;master&quot;, rank=0, world_size=2)
  rref = torch.Tensor([0])
  sub_fun(rref)
  rpc.shutdown()
  </code></pre>
  <p>test.py</p>
  <pre class="lang-py prettyprint-override"><code>
  def f(rref):
  print(&quot;function is executed on master&quot;)
  
  def sub_fun(rref):
  x = rpc.rpc_async(&quot;worker&quot;, f, args=(rref,))
  </code></pre>
  <p>worker.py:</p>
  <pre class="lang-py prettyprint-override"><code>import os
  import torch
  import torch.distributed.rpc as rpc
  from torch.distributed.rpc import RRef
  
  os.environ['MASTER_ADDR'] = '10.5.26.19'
  os.environ['MASTER_PORT'] = '5677'
  
  def f(rref):
  print(&quot;function is executed on worker&quot;)
  rpc.init_rpc(&quot;worker&quot;, rank=1, world_size=2)
  rpc.shutdown()
  </code></pre>
  <p>I found that the output is &quot;function is executed on master&quot; at the worker side.</p>
  <h4>Method 2</h4>
  <p>when I put the two functions: sub_fun and f in the master.py rather than the test.py, the result is &quot;function is executed on worker&quot;.</p>
  <p>Why the two ways output the different results. and how can I get the result 2 with the method 1.</p>