human
Solve the following python programming problem given the following code:
@snippet
def subscription_pull(client, to_delete):
assistant
#Here is the Python program you requested.

    """Pull messges from a subscribed topic.
    """
    TOPIC_NAME = ('subscription_pull-%d' % (_millis(),))
    SUB_NAME = ('subscription_pull-defaults-%d' % (_millis(),))
    PAYLOAD1 = 'PAYLOAD1'
    PAYLOAD2 = 'PAYLOAD2'
    EXTRA = 'EXTRA'
    topic = client.topic(TOPIC_NAME)
    topic.create()
    to_delete.append(topic)
    subscription = topic.subscription(SUB_NAME)
    subscription.create()
    to_delete.append(subscription)
    pulled = subscription.pull(return_immediately=True)
    assert (len(pulled) == 0), 'unexpected    message'
    topic.publish(PAYLOAD1)
    topic.publish(PAYLOAD2, extra=EXTRA)
    time.sleep(1)
    pulled = subscription.pull(max_messages=2)
    assert (len(pulled) == 2), 'eventual    consistency'
    for (ack_id, _) in pulled:
        subscription.modify_ack_deadline(ack_id, 90)
    payloads = []
    extras = []
    def do_something_with(message):
        payloads.append(message.data)
        if message.attributes:
            extras.append(message.attributes)
    class ApplicationException(Exception, ):
        pass
    def log_exception(_):
        pass
    for (ack_id, message) in pulled:
        try:
            do_something_with(message)
        except ApplicationException as e:
            log_exception(e)
        else:
            subscription.acknowledge([ack_id])
    assert (set(payloads) == set([PAYLOAD1, PAYLOAD2])), ('payloads:    %s' % (payloads,))
    assert (extras == [{'extra': EXTRA}]), ('extras:    %s' % (extras,))