Skip to content

Commit b2af9ca

Browse files
authored
Missing data validity check (#1269)
* Missing data validity check Signed-off-by: zesk1999 <zesk1999@gmail.com> * Review applied Signed-off-by: zesk1999 <zesk1999@gmail.com> --------- Signed-off-by: zesk1999 <zesk1999@gmail.com>
1 parent fa99fd0 commit b2af9ca

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

code/Examples/Python/HelloWorld/HelloWorldSubscriber.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def on_data_available(self, reader):
4545
data = HelloWorld.HelloWorld()
4646
reader.take_next_sample(data, info)
4747

48-
print("Received {message} : {index}".format(message=data.message(), index=data.index()))
48+
if info.valid_data:
49+
print("Received {message} : {index}".format(message=data.message(), index=data.index()))
4950

5051

5152
class Reader:

docs/fastdds/getting_started/simple_python_app/includes/subscriber.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,25 @@ The next line defines the :class:`Reader` class that implements a subscriber.
4545

4646
.. literalinclude:: /../code/Examples/Python/HelloWorld/HelloWorldSubscriber.py
4747
:language: python
48-
:lines: 51
48+
:lines: 52
4949

5050
Next comes the subscriber initialization public member function.
5151
This is the same as the initialization public member function defined for the :class:`Writer`.
5252

5353
.. literalinclude:: /../code/Examples/Python/HelloWorld/HelloWorldSubscriber.py
5454
:language: python
55-
:lines: 54-76
55+
:lines: 55-77
5656
:dedent: 4
5757

5858
The public member function :func:`run` ensures that the subscriber runs until the user press *Ctrl+C*.
5959

6060
.. literalinclude:: /../code/Examples/Python/HelloWorld/HelloWorldSubscriber.py
6161
:language: python
62-
:lines: 85-89
62+
:lines: 86-90
6363
:dedent: 4
6464

6565
Finally, the participant that implements a subscriber is initialized and run in main.
6666

6767
.. literalinclude:: /../code/Examples/Python/HelloWorld/HelloWorldSubscriber.py
6868
:language: python
69-
:lines: 92-96
69+
:lines: 93-97

0 commit comments

Comments
 (0)