Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions nameko-examples/nameko_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from nameko.exceptions import RemoteError
import os
from datetime import datetime
import time

CONFIG = {
"AMQP_URI": "pyamqp://{}:{}@{}/".format(
Expand Down Expand Up @@ -60,6 +61,16 @@ def fibonacci(n: int = 10) -> list[int]:
data.append(rpc.video.fibonacci(i))
return data

def async_fibonacci(n: int = 10) -> list[int]:
"""
fibonacci send a message to the queue
"""
data = list()
with rpc_proxy(CONFIG) as rpc:
for i in range(n):
data.append(rpc.video.fibonacci.call_async(i))
return [d.result() for d in data]


if __name__ == "__main__":
start = datetime.now()
Expand All @@ -69,10 +80,8 @@ def fibonacci(n: int = 10) -> list[int]:
response = send_messages("John Doe", 10)
print(response, datetime.now() - start)
start = datetime.now()
response = fibonacci(10)
response = fibonacci(40)
print(response, datetime.now() - start)
try:
response = send_simple_message(True)
except RemoteError as e:
print(e)

start = datetime.now()
response = async_fibonacci(40)
print(response, datetime.now() - start)