parameters: (self)
docstring: Completely cleanout all available containers in the pool and immediately
          schedule their replacement. Useful for refilling the pool with a new
          container image while leaving in-use containers untouched. Returns the
          number of containers drained.
docstring_summary: Completely cleanout all available containers in the pool and immediately
          schedule their replacement. Useful for refilling the pool with a new
          container image while leaving in-use containers untouched. Returns the
          number of containers drained.
docstring_tokens: Completely cleanout all available containers in the pool and immediately schedule their replacement . Useful for refilling the pool with a new container image while leaving in - use containers untouched . Returns the number of containers drained .
function: def drain(self):
          '''
          Completely cleanout all available containers in the pool and immediately
          schedule their replacement. Useful for refilling the pool with a new
          container image while leaving in-use containers untouched. Returns the
          number of containers drained.
          '''
          app_log.info("Draining available containers from pool")
          tasks = []
          while 1:
              try:
                  pooled = self.acquire()
                  app_log.debug("Releasing container [%s] to drain the pool.", pooled.id)
                  tasks.append(self.release(pooled, replace_if_room=False))
              except EmptyPoolError:
                  # No more free containers left to acquire
                  break
          yield tasks
          raise gen.Return(len(tasks))
function_tokens: def drain ( self ) : app_log . info ( "Draining available containers from pool" ) tasks = [ ] while 1 : try : pooled = self . acquire ( ) app_log . debug ( "Releasing container [%s] to drain the pool." , pooled . id ) tasks . append ( self . release ( pooled , replace_if_room = False ) ) except EmptyPoolError : # No more free containers left to acquire break yield tasks raise gen . Return ( len ( tasks ) )