2013-02-14 2 views
6

RabbitMQ 튜토리얼에서 기본 RPC 예제를 수정하여 RPC 서버 역할을하는이 python 스크립트는 here입니다. 그것은 내 노트북에서 잘 실행됩니다. 하지만 난이 사양과 아마존 EC2 높은 CPU 중간 인스턴스에서 그것을 실행하면 메모리의100 % CPU를 사용하는 RabbitMQ python 작업자 스크립트

1.7 지브

5 개 EC2 컴퓨팅 유닛

(2.5 EC2 컴퓨팅 유닛 각각 2 개 가상 코어) 인스턴스 저장소 350GB

CPU가 100 % 차지합니다. 거의 동일한 구성을 가진 내 랩탑이 4 % 미만의 CPU 사용량으로이를 실행하지만, 랩톱과 아마존 모두에서 우분투 -12.04를 실행합니다. 여기

#!/usr/bin/env python 
    import pika 
    import commands 
    import socket 
    import base64 

    connection = pika.BlockingConnection(pika.ConnectionParameters(
      host='localhost')) 
    channel = connection.channel() 
    channel.queue_declare(queue='rpc_queue') 
    def on_request(ch, method, props, body): 
     #print body 
     body = base64.b64decode(body) 
     print body 
     run = commands.getoutput(body) 
     response = socket.gethostname() 
     print response 
     ch.basic_publish(exchange='', 
         routing_key=props.reply_to, 
         properties=pika.BasicProperties(correlation_id = \ 
                 props.correlation_id), 
         body=str(response)) 
     ch.basic_ack(delivery_tag = method.delivery_tag) 
    channel.basic_qos(prefetch_count=1) 
    channel.basic_consume(on_request, queue='rpc_queue') 
    print " [x] Awaiting RPC requests" 
    channel.start_consuming() 

가 어떻게이 문제를 해결할 수 있습니다 내 코드?

답변

5

마지막으로 문제가 발견되었습니다. Pika의 버그였습니다. rabbitmq의 메일 링리스트에서이 정보를 얻었습니다. 나는 pypi를 통해 pika를 설치했다. pip install pika.

내가 새앙 토끼

pip uninstall pika

을 제거하고 자식

pip install git+https://github.com/pika/pika.git에서 다시 설치이 문제를 해결합니다.

그리고 해결되었습니다.

+1

문제에 대한 링크를 제공하면 좋을 것입니다. 나는 아주 긴 시간을 알고있다. 그러나 그것은 많은 도움이됩니다! –

+0

@HariKrishnan이 버그는 https://github.com/pika/pika/issues/361입니다. –

관련 문제