call site 7 for execnet.SocketGateway.remote_exec
execnet/testing/test_gateway.py - line 296
294
295
296
297
298
299
300
301
   def test_remote_redirect_stdout(self): 
       out = py.std.StringIO.StringIO() 
->     handle = self.gw._remote_redirect(stdout=out) 
       c = self.gw.remote_exec("print 42")
       c.waitclose(TESTTIMEOUT)
       handle.close() 
       s = out.getvalue() 
       assert s.strip() == "42" 
execnet/gateway.py - line 306
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
   def _remote_redirect(self, stdout=None, stderr=None): 
       """ return a handle representing a redirection of a remote 
               end's stdout to a local file object.  with handle.close() 
               the redirection will be reverted.   
           """ 
       clist = []
       for name, out in ('stdout', stdout), ('stderr', stderr): 
           if out: 
               outchannel = self.newchannel()
               outchannel.setcallback(getattr(out, 'write', out))
               channel = self.remote_exec(""" 
                       import sys
                       outchannel = channel.receive() 
                       outchannel.gateway._ThreadOut(sys, %r).setdefaultwriter(outchannel.send)
->                 """ % name) 
               channel.send(outchannel)
               clist.append(channel)
       for c in clist: 
           c.waitclose() 
       class Handle: 
           def close(_): 
               for name, out in ('stdout', stdout), ('stderr', stderr): 
                   if out: 
                       c = self.remote_exec("""
                               import sys
                               channel.gateway._ThreadOut(sys, %r).resetdefault()
                           """ % name) 
                       c.waitclose() 
       return Handle()