Skip to content

Added sequences support on pyopendds [#18]#20

Closed
Sdpierret wants to merge 3 commits intoOpenDDS:masterfrom
Sdpierret:sequences
Closed

Added sequences support on pyopendds [#18]#20
Sdpierret wants to merge 3 commits intoOpenDDS:masterfrom
Sdpierret:sequences

Conversation

@Sdpierret
Copy link

This PR add sequences support to pyopendds.

depends #19

Sdpierret added 2 commits May 18, 2021 14:07
Add basic support for publisher

know issue : Segfault after write() call

Signed-off-by: David Pierret <david.pierret@smile.fr>
manage sequences as list
@iguessthislldo iguessthislldo linked an issue Jun 7, 2021 that may be closed by this pull request
Copy link
Member

@iguessthislldo iguessthislldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a partial review. I still need to review the changes in itl2py and _pyopendds.cpp and look into the issue below. It's getting late for me and I'd like to give you at least some feedback since I've taken so long to review what you've been doing.

The issue I mentioned is I'm getting a segfault as Python is exiting when I try to run the test on my laptop. That is might not be your fault because it's something I once thought might happen when the Python objects are being destroyed, but I'm still looking into it. However before the segfault is happening I can see it's printing out the message, so it's exciting to see that part works!

'''

args = list(args)
args = list(sys.argv[1:])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a problem with it being possible, but this isn't opt-in anymore like it is in a C++ OpenDDS application, where you have to explicitly give TheParticipantFactoryWithArgs the program arguments. What do you think about making this conditional on keyword argument like from_argv?

publisher = domain.create_publisher()
writer = publisher.create_datawriter(topic)

# Wait for Publisher to Connect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Wait for Publisher to Connect
# Wait for Subscriber to Connect

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
// TODO: Encode or Throw Unicode Error
PyObject* repr = PyObject_Repr(py);
PyObject* str = PyUnicode_AsEncodedString(repr, "utf-8", "~E~");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itl2py could set an encoding other than UTF-8. Also this also needs to throw if it failed.

Suggested change
PyObject* str = PyUnicode_AsEncodedString(repr, "utf-8", "~E~");
PyObject* str = PyUnicode_AsEncodedString(repr, encoding, "~E~");
if (!str) throw Exception();

Also what's "~E~" do? I don't see it in the documentation for this function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, "E" is the default string in case of error. replaced by NULL

Comment on lines +260 to +265
// Wait for samples to be acknowledged
DDS::Duration_t timeout = { 30, 0 };
if (writer_impl->wait_for_acknowledgments(timeout) != DDS::RETCODE_OK) {
throw Exception(
"wait_for_acknowledgments error : ", Errors::PyOpenDDS_Error());
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a separate operation like it is in OpenDDS, because this could be a lengthy process depending on how much stuff is being sent and to how many peers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, it's needed as a separate function on our application too.

PyObject* write(PyObject* pywriter, PyObject* pysample)
{
DDS::DataWriter* writer = get_capsule<DDS::DataWriter>(pywriter);
if (!writer) PyErr_SetString(PyExc_Exception, "writer is a NULL pointer");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!writer) PyErr_SetString(PyExc_Exception, "writer is a NULL pointer");
if (!writer) throw Exception();

So PyErr_SetString doesn't stop this function from running. All it does is set up an exception that the interrupter will throw when it has the chance. Also get_capsule is already setting PyErr_SetString, all we would have to do here is to stop running this function, which is the purpose of throwing Exception() (with no arguments).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: David Pierret <david.pierret@smile.fr>
@iguessthislldo
Copy link
Member

Closing in favor of #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants