Skip to content

Commit 7986977

Browse files
committed
Fix buffering issue on pubsub example test
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
1 parent 23457d1 commit 7986977

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

examples/pubsub-streaming-async/publisher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def publish_events():
4444
)
4545

4646
# Print the request
47-
print(req_data, flush=True)
47+
print(req_data)
4848

4949
await asyncio.sleep(1)
5050

examples/pubsub-streaming-async/subscriber.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def process_message(message):
1919
global counter
2020
counter += 1
2121
# Process the message here
22-
print(f'Processing message: {message.data()} from {message.topic()}...', flush=True)
22+
print(f'Processing message: {message.data()} from {message.topic()}...')
2323
return 'success'
2424

2525

tests/examples/test_pubsub_streaming_async.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"Processing message: {'id': 3, 'message': 'hello world'} from TOPIC_B1...",
77
"Processing message: {'id': 4, 'message': 'hello world'} from TOPIC_B1...",
88
"Processing message: {'id': 5, 'message': 'hello world'} from TOPIC_B1...",
9+
"Closing subscription...",
910
]
1011

1112
EXPECTED_HANDLER_SUBSCRIBER = [
@@ -14,6 +15,7 @@
1415
"Processing message: {'id': 3, 'message': 'hello world'} from TOPIC_B2...",
1516
"Processing message: {'id': 4, 'message': 'hello world'} from TOPIC_B2...",
1617
"Processing message: {'id': 5, 'message': 'hello world'} from TOPIC_B2...",
18+
"Closing subscription...",
1719
]
1820

1921
EXPECTED_PUBLISHER = [
@@ -28,12 +30,12 @@
2830
@pytest.mark.example_dir('pubsub-streaming-async')
2931
def test_pubsub_streaming_async(dapr):
3032
dapr.start(
31-
'--app-id python-subscriber --app-protocol grpc -- python3 subscriber.py --topic=TOPIC_B1',
33+
'--app-id python-subscriber --app-protocol grpc -- python3 -u subscriber.py --topic=TOPIC_B1',
3234
wait=5,
3335
)
3436
publisher_output = dapr.run(
3537
'--app-id python-publisher --app-protocol grpc --dapr-grpc-port=3500 '
36-
'--enable-app-health-check -- python3 publisher.py --topic=TOPIC_B1',
38+
'--enable-app-health-check -- python3 -u publisher.py --topic=TOPIC_B1',
3739
timeout=30,
3840
)
3941
for line in EXPECTED_PUBLISHER:
@@ -47,12 +49,12 @@ def test_pubsub_streaming_async(dapr):
4749
@pytest.mark.example_dir('pubsub-streaming-async')
4850
def test_pubsub_streaming_async_handler(dapr):
4951
dapr.start(
50-
'--app-id python-subscriber --app-protocol grpc -- python3 subscriber-handler.py --topic=TOPIC_B2',
52+
'--app-id python-subscriber --app-protocol grpc -- python3 -u subscriber-handler.py --topic=TOPIC_B2',
5153
wait=5,
5254
)
5355
publisher_output = dapr.run(
5456
'--app-id python-publisher --app-protocol grpc --dapr-grpc-port=3500 '
55-
'--enable-app-health-check -- python3 publisher.py --topic=TOPIC_B2',
57+
'--enable-app-health-check -- python3 -u publisher.py --topic=TOPIC_B2',
5658
timeout=30,
5759
)
5860
for line in EXPECTED_PUBLISHER:

0 commit comments

Comments
 (0)