Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for timeout #11

Open
GoogleCodeExporter opened this issue Nov 2, 2015 · 12 comments
Open

Support for timeout #11

GoogleCodeExporter opened this issue Nov 2, 2015 · 12 comments

Comments

@GoogleCodeExporter
Copy link

Versions: py-amqplib 0.6.1, RabbitMQ 1.5.4, Python 2.6.4

I would like to perform the following:

  chan.basic_consume(..)
  heartbeat_deadline = new_deadline(...) # Compute a time instant
  while 1:
    next_deadline = max(0, heartbeat_deadline - time.time())
    chan.wait(timeout = next_deadline)
    # We get there if a message was processed,
    # or if nothing was received for the specified amount of time.
    # Check if we reached our deadline:
    if time.time() > heartbeat_deadline:
       chan.basic_publish(...)
       heartbeat_deadline = new_deadline(...)

The purpose is to allow me to run a loop to receive new messages from
a queue synchronously, but that still allow me to send message back to
the server at regular interval (like heartbeat or something like that.)

Could py-ampqlib support that easily? I've not checked sources in detail,
but I think _AbstractTransport._read(self, n) could support an additionnal
parameter 'timeout', which would be used only for receiving the header
of a new frame (other uses would set timeout to None) if .wait() specified
a timeout itself, using select() before the read() operation.

But maybe I misusing the library. Is that another way to obtain the same
behavior? I thought about writing a second process (and thus opening
an additionnal TCP connection) but I'm not really happy with this idea.
I would prefer to perform all the stuff from a single process.

Original issue reported on code.google.com by [email protected] on 21 Jan 2010 at 2:37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant