RabbitMQ + SelectConnection in Python

290 views
Skip to first unread message

Marcin Olchowka

unread,
Oct 21, 2020, 10:16:50 AM10/21/20
to rabbitmq-users


Hi everyone,
I have a problem with connection to RabbitMQ using pika.SelectConnection adapter. I am using Pika 1.1.0 and Python 3.7.9.
Below snapshot of my code showing how I am creating connection.

import pika

def on_done():
    connect.channel()
    print("Open Callback")

if __name__ == '__main__':
    account = "user"
    password = "password"
    server = "172.17.0.5"
    credentials = pika.PlainCredentials(account, password)
    parameters = pika.ConnectionParameters(host=server, port=15672, credentials=credentials,                  socket_timeout=10)
    connect = pika.SelectConnection(parameters, on_open_callback=on_done)
   
    connect.ioloop.start()

RabbitMQ is running, I have checked connection using pika.BlockingConnection adapter.
What is strange, my IDE (Pyharm) is highliting start() function as "Unresolved attribute reference 'start' for class 'object'". When I run this code, nothing error is occured. On admin webpage I don't see that connection is opened.

Has somebody meet similar problem?

Thank you for help!!

Luke Bakken

unread,
Oct 21, 2020, 10:37:24 AM10/21/20
to rabbitmq-users
Hello,

Please see the asynchronous examples here for how to use SelectConnection:


I can't assist as to why your IDE is behaving that way. I suggest asking in a Pyharm or Python specific support forum.

Thanks,
Luke

Marcin Olchowka

unread,
Oct 22, 2020, 6:09:56 AM10/22/20
to rabbitmq-users
Thank you Luke for answer and examples.
SelectConnection adapter is working although my IDE highlighting that unresolved attribute reference for start() function.

Best regards

Shantha Dodmane

unread,
Nov 2, 2020, 4:04:02 AM11/2/20
to rabbitm...@googlegroups.com
Hello  Marcin Olchowka,

I am facing the same issue. Did you get the solution for the same? I don't think it has do something with PyCharm IDE. 

Thanks,
Shantha Dodmane


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/d4a73570-703c-4bad-b6bb-d9f3e00f5753n%40googlegroups.com.

Marcin Olchowka

unread,
Nov 2, 2020, 8:16:50 AM11/2/20
to rabbitmq-users
Hi,
My PyCharm IDE is highlighting ioloop.start(), I have not had time to understand why, but connection with RabbitMQ is working. I did connection as Luke suggested in example.
If something is wrong with definition in pika.SelectConnection(....) the messages can not been passed to RabbitMQ and doesn't depends on highlighting ioloop.start() by IDE.

Best regards
Marcin
Reply all
Reply to author
Forward
0 new messages