Hello, so I am not sure if this is a bug or I am just not using this correctly, but I'd like some feedback on something...
to set up an async publisher.
Other than the `
connection.close()` needing to be removed in my code otherwise it falls over, this works fine when sending a single message.
The problems start happening when I start wanting to send large amounts of messages.
def on_channel_open(channel):
i = 0
while True:
channel.basic_publish('test_exchange',
'test_routing_key',
'message body value',
pika.BasicProperties(content_type='text/plain',
delivery_mode=1))
i += 1
if i % 100_000 == 0:
print(f'Sent {i} messages so far...')
```
And then run it it will sit there saying it has sent messages but will never actually deliver any to the queue (and yes, I have the queue actually set up so that in the case of a non-continuous set of messages they will be delivered).
If I ctrl+C the process then it will strop this loop, and only then will it start publishing messages to the queue.
This is a somewhat simplified example of the problem I have with my actual code is but it does indicate the issue. In my proper code I have a publisher class which takes in a multiprocessing queue and then reads from it to publish messages (I wanted some way to allow pushing messages to the class when it's run in a separate process).
The main body of that code is based on the async publisher example found
here and with the PUBLISH_INTERVAL set to 0. This massively reduces the rate at which messages can be published however (simple example code can do about 20k/s whereas this full async publisher only hits about 3k/s)
I did find a way to get a bit more performance and that was in each publish loop to send of 10 messages for publishing before calling the `schedule_next_message` function, but then if the publishing occurs slowly messages only get published in blocks of 10's, sometimes 20's or 30's which is what tipped me off to this in the first place.
Anyway, sorry for all the text, hopefully this makes sense and I'd love some feedback on this as I'm not sure if this is actually a bug that the sending doesn't actually happen or whether I need to do something else so that it works (and hopefully keeps the same performance!)
Thanks!