nimi-python icon indicating copy to clipboard operation
nimi-python copied to clipboard

Add support for gRPC session options as a separate class

Open dmondrik opened this issue 2 years ago • 0 comments

  • [X] This contribution adheres to the spirit of CONTRIBUTING.md.
    • Running tox failed with py37-test as a key.
    • There were no installers for me to use.
    • I was unable to run system tests.

TODO: Check the above box with an 'x' indicating you've read and followed CONTRIBUTING.md.

TODO: Check the above box with an 'x' if considered if there were any and then documented client facing changes in CHANGELOG.md. Strike through if this is not a relevant client facing change.

  • [ ] I've added tests applicable for this pull request

TODO: Check the above box with an 'x' indicating you have considered and added any applicable system or unit tests. Strike through if you considered and decided additional tests were not warranted.

What does this Pull Request accomplish?

Multiple gRPC options are necessary to satisfy all business requirements. Putting them into a single object makes the Session constructor simpler.

Task 2186992: [nimi-python] Pass init/attach fields properly in GrpcStubInterpreter

List issues fixed by this Pull Request below, if any.

N/A

What testing has been done?

Test setup: Windows VM with NI-DMM installed and the latest artifact build of the gRPC Device Server. (The installer includes an older binary; Johann has since updated that.) I created a simulated 4065. I used I/O Trace to verify which calls were made from what process.

Test procedure: 5 tiny .py tests always having a with statement to ensure the session went out of scope properly.

  • First I wrote a simple Session that read a value using the local native driver. The session was closed.
  • The rest used gRPC. In the session options I specified behavior=INITIALIZE_NEW and close=False. It created a session and left it open.
  • Running the same program again, it threw a python exception because the gRPC session was already initialized. No driver calls were made.
  • I changed the session options to behavior=ATTACH_TO_EXISTING and close=True. It read the value using the existing session and then closed it.
  • Running the same program again, it threw a python exception because there was no session to which it could attach. No driver calls were made.

dmondrik avatar Oct 24 '22 21:10 dmondrik