Disable JSON encoding for interprocess communication #301
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Queue Server is using JSON RPC protocol for communication between the manager process and other processes. In this PR the communication code is modified so that the messages are not encoded as JSON string by the process sending the message and the decoded by the receiving process. Conversion data (e.g. a large array) to and from a JSON string is slow and completely unnecessary for interprocess communication within one application. Instead, the JSON RPC message is sent as a dictionary via
multiprocessing.Pipe
, which automatically pickles the outgoing message and then unpickles it at the receiving end. The change does not affect user-facing API, but is expected to make Queue Server more stable due to shorter interprocess communication delays.Other changes:
json-rpc
package is replaced with custom implementation of JSON RPC handler, which supports the option to enable/disable JSON encoding (json-rpc
is no longer a dependency); new parameteruse_json
in the constructors ofPipeJsonRpcReceive
andPipeJsonRpcSendAsync
classes; better processing ofSIGTERM
by the watchdog process, which is now reliably closes the manager and the worker processes (e.g. ifkill <pid>
is called on the watchdog process, it does not work withkill -9 <pid>
)