The handle_message method of provider is never executed

Hi,

I’m trying to consume amqp messages by following the Example in nameko.messaging module,but failed.

@consume(queue = queue)
def handle_message(self, message):

I found that the messages are received,and handle_message is spawned in spawn_managed_thread(nameko/containers.py),but isn’t executed for some reason,which I tried very hard but failed to figure out.

The following is what I get by adding “print(fn)” in spawn_managed_thread method:
functools.partial(<bound method Consumer.handle_message of <Consumer [LibvirtCIKojiWatcherService.handle_message] at 0x7fa6ec8f6b50>>, {‘mlist’: {‘list_name’: ‘package-announce’}, ‘msg’: {‘archived-at’: ‘https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/J5IAOAVQXTSTN67OMO3L4HSZB4RQP27Y/’, ‘cc’: None, ‘delivered-to’: None, ‘from’: ‘updates@fedoraproject.org’, ‘in-reply-to’: None, ‘message-id’: ‘20201230013913.4130330A5C71@bastion01.iad2.fedoraproject.org’, ‘references’: None, ‘subject’: ‘Fedora 33 Update: golang-github-pborman-uuid-1.2.1-1.fc33’, ‘to’: ‘package-announce@lists.fedoraproject.org’, ‘user-agent’: None, ‘x-mailman-rule-hits’: ‘nonmember-moderation’, ‘x-mailman-rule-misses’: ‘dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3’, ‘x-message-id-hash’: ‘J5IAOAVQXTSTN67OMO3L4HSZB4RQP27Y’}}, <Message object at 0x7fa6ec88f9d0 with details {‘state’: ‘RECEIVED’, ‘content_type’: ‘application/json’, ‘delivery_tag’: 2, ‘body_length’: 828, ‘properties’: {}, ‘delivery_info’: {‘exchange’: ‘zmq.topic’, ‘routing_key’: ‘org.fedoraproject.prod.mailman.receive’}}>)

What are you expecting to happen that is not happening?

It certainly looks like your message is being received. If you replace your print(fn) with a pdb.set_trace(), or put one in LibvirtCIKojiWatcherService.handle_message, you should be able to step through what is actually happening.

If you can provide example code to reproduce that would be helpful too.

Hi,

What are you expecting to happen that is not happening?

I add one print line at the beginning of LibvirtCIKojiWatcherService.handle_message,
it’s not printed,I also add pdb.set_trace() at the beginning,and the program didn’t stop.

If you can provide example code to reproduce that would be helpful too

Here is the code link:

Just pip install it,and execute"koji-watcher --email-notify --registry Openshift"

You need to add the code in my PR to have it work:)

I think the problem here is that you’re never calling eventlet.monkey_patch.

See the note at the bottom of the docs here about that.

The monkey patch gives Eventlet the ability to switch threads when something blocks for I/O. Without it, threads will block. Essentially your service is deadlocked.

Make sure to apply the monkey patch before any imports, otherwise you don’t import the patched versions.

Yes,after adding eventlet.monkey_patch, my problem is solved,thanks for your information and help.
Would you please review my PR[1] when you get some time to spare?Thanks.

[1]provide a way to config login_method by skycastlelily · Pull Request #713 · nameko/nameko · GitHub