def _loopbackAsyncBody(server, serverToClient, client, clientToServer, pumpPolicy):
 def pump(source, q, target):
  sent = False
  if q:
   pumpPolicy(q, target)
   sent = True
  if (sent and (not q)):
   source.transport._pollProducer()
  return sent
 while 1:
  disconnect = clientSent = serverSent = False
  serverSent = pump(server, serverToClient, client)
  clientSent = pump(client, clientToServer, server)
  if ((not clientSent) and (not serverSent)):
   d = defer.Deferred()
   clientToServer._notificationDeferred = d
   serverToClient._notificationDeferred = d
   d.addCallback(_loopbackAsyncContinue, server, serverToClient, client, clientToServer, pumpPolicy)
   return d
  if serverToClient.disconnect:
   disconnect = True
   pump(server, serverToClient, client)
  elif clientToServer.disconnect:
   disconnect = True
   pump(client, clientToServer, server)
  if disconnect:
   server.connectionLost(failure.Failure(main.CONNECTION_DONE))
   client.connectionLost(failure.Failure(main.CONNECTION_DONE))
   return defer.succeed(None)

def _loopbackAsyncBody ( server , serverToClient , client , clientToServer , pumpPolicy ) : def pump ( source , q , target ) : sent = False if q : pumpPolicy ( q , target ) sent = True if ( sent and ( not q ) ) : source . transport . _pollProducer ( ) return sent while 1 : disconnect = clientSent = serverSent = False serverSent = pump ( server , serverToClient , client ) clientSent = pump ( client , clientToServer , server ) if ( ( not clientSent ) and ( not serverSent ) ) : d = defer . Deferred ( ) clientToServer . _notificationDeferred = d serverToClient . _notificationDeferred = d d . addCallback ( _loopbackAsyncContinue , server , serverToClient , client , clientToServer , pumpPolicy ) return d if serverToClient . disconnect : disconnect = True pump ( server , serverToClient , client ) elif clientToServer . disconnect : disconnect = True pump ( client , clientToServer , server ) if disconnect : server . connectionLost ( failure . Failure ( main . CONNECTION_DONE ) ) client . connectionLost ( failure . Failure ( main . CONNECTION_DONE ) ) return defer . succeed ( None )
transfer bytes from the output queue of each protocol to the input of the other .