Skip to content

How can I perform a long task #5154

Discussion options

You must be logged in to vote

It is documented here:
https://pika.readthedocs.io/en/stable/examples/heartbeat_and_blocked_timeouts.html

Here the example:
https://github.com/pika/pika/blob/main/examples/heartbeat_and_blocked_timeouts.py

import pika
import time
from datetime import datetime


class Consumer:
    def __init__(self):
        params = pika.ConnectionParameters(heartbeat=600, blocked_connection_timeout=300)
        connection = pika.BlockingConnection(params)
        self._channel = connection.channel()

    def start(self):
        start = datetime.now() 
        def on_message_callback(channel, method, properties, body):
            print(body)
            for i in range(3600):
                print("seco…

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@dabbler0606
Comment options

@dabbler0606
Comment options

@Gsantomaggio
Comment options

@michaelklishin
Comment options

@Gsantomaggio
Comment options

Answer selected by Gsantomaggio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants