pythonrabbitmqlocustpika

Unable to perform RMQ publish from Locust "BlockingIOError: [WinError 10035]"


My project requires client sending messages directly to Rabbit MQ and we need to do load testing for this.

I tried PIKA, works fine in a plain python file but as soon as I tried to implement this in Locust I start getting error due to compatibility issues

I tried PIKA Async, B-Rabbit, etc.. none works with Locust(Gevent)

I dont have to integrate with locust but just importing locust on these python file is enough to trigger the error.

I have read in several blogs that Gevent is not compatible with pika.

class RMQ:

    def __init__(self) -> None:
        self.connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', credentials=pcredentails))
        self.channel = self.connection.channel()

    def connect(self):
        self.channel.basic_publish(exchange='locust_events', routing_key='python3', body='Hello World!')
        print("[x] Sent 'Hello World!'")

    def close(self):
        self.channel.close()
        self.connection.close()

Error:

BlockingIOError: [WinError 10035] A non-blocking socket operation could not be completed immediately

Some one please let me know a possible way to solve this

Note: B-rabbit did say it is thread safe but it still throws error when I publish "Time out reading from server" with 12s delay, this happens only when I use locust else it is fast


Solution

  • Having tried

    **Pika** = not compatible with Gevent Locust (esp windows)
    
    **B-rabbit**, **Rabbit-py** = Slow with locust and times out
    

    I can confirm Kombu works perfectly with Locust, anyone looking to implement queues with locust this is the solution

    https://github.com/celery/kombu

    enter image description here