def drain_to(self, list, max_size=-<NUM_LIT:1>):
def drain_result(f):<EOL><INDENT>resp = f.result()<EOL>list.extend(resp)<EOL>return len(resp)<EOL><DEDENT>return self._encode_invoke(queue_drain_to_max_size_codec, max_size=max_size).continue_with(<EOL>drain_result)<EOL>
Transfers all available items to the given `list`_ and removes these items from this queue. If a max_size is
specified, it transfers at most the given number of items. In case of a failure, an item can exist in both
collections or none of them.

This operation may be more efficient than polling elements repeatedly and putting into collection.

:param list: (`list`_), the list where the items in this queue will be transferred.
:param max_size: (int), the maximum number items to transfer (optional).
:return: (int), number of transferred items.

.. _list: https://docs.python.org/2/library/functions.html#list