Skip to content

Commit c1b178d

Browse files
committed
Fixed bug in tutorial 6 caused by misunderstanding of stop_consuming().
Apparently stop_consuming() does basic.cancel. Which is completely not what we want. Instead of using start/stop consuming, let's just do the busy loop by ourselves.
1 parent fba096f commit c1b178d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

python/rpc_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def __init__(self):
1818
def on_response(self, ch, method, props, body):
1919
if self.corr_id == props.correlation_id:
2020
self.response = body
21-
self.channel.stop_consuming()
2221

2322
def call(self, n):
23+
self.response = None
2424
self.corr_id = str(uuid.uuid4())
2525
self.channel.basic_publish(exchange='',
2626
routing_key='rpc_queue',
@@ -29,7 +29,8 @@ def call(self, n):
2929
correlation_id = self.corr_id,
3030
),
3131
body=str(n))
32-
self.channel.start_consuming()
32+
while self.response is None:
33+
self.connection.process_data_events()
3334
return int(self.response)
3435

3536
fibonacci_rpc = FibonacciRpcClient()

0 commit comments

Comments
 (0)