def collapsingPumpPolicy(queue, target):
 bytes = []
 while queue:
  chunk = queue.get()
  if (chunk is None):
   break
  bytes.append(chunk)
 if bytes:
  target.dataReceived(''.join(bytes))

def collapsingPumpPolicy ( queue , target ) : bytes = [ ] while queue : chunk = queue . get ( ) if ( chunk is None ) : break bytes . append ( chunk ) if bytes : target . dataReceived ( '' . join ( bytes ) )
l{collapsingpumppolicy} is a policy which collapses all outstanding chunks into a single string and delivers it to the target .