-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: extract _send_windows_request
to the named_pipe_helper.py
#32
Conversation
c967552
to
c435098
Compare
Signed-off-by: Hongli Chen <[email protected]>
c435098
to
5364702
Compare
@@ -82,6 +82,9 @@ def instance_thread(self) -> None: | |||
f"Encountered an error while sending the error response: {traceback.format_exc()}." | |||
) | |||
try: | |||
# Flush the pipe to allow the client to read the pipe's contents before disconnecting. | |||
# Then disconnect the pipe, and close the handle to this pipe instance. | |||
win32file.FlushFileBuffers(self.pipe_handle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not related to the code refactoring but just one line change so I put it here. This is required and I missed this before. Reference: https://learn.microsoft.com/en-us/windows/win32/ipc/multithreaded-pipe-server
return f"{self.message} (Error code: {self.error_code})" | ||
|
||
|
||
class NamedPipeHelper: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
send_named_pipe_request
and establish_named_pipe_connection
are two new methods. The code is copied fro m the _send_windows_request
, Other code exists in the old file. Due to renaming, all text have green background
Signed-off-by: Robert Luttrell <[email protected]>
What was the problem/requirement? (What/Why)
Need to send request in the Adaptor Server client and the Background client. There are some common code could be reused.
What was the solution? (How)
named_pipe_helper.py
to the_named_pipe
folder_send_windows_request
to thenamed_pipe_helper
and rename it tosend_named_pipe_request
win32file.FlushFileBuffers(self.pipe_handle)
before closing the named pipe to ensure that all messages are read by the client.What is the impact of this change?
Just refactoring. Nothing is changed.
How was this change tested?
All tests are passed.
Was this change documented?
No
Is this a breaking change?
No
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.