Skip to content

Commit

Permalink
applied potential fix to deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nedvedba committed Jan 16, 2025
1 parent 39814b4 commit 5c70a5e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions python/datafed_pkg/datafed/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# registerProtocol() method then loads uses this information to create
# consistent message type framing for python send/recv methods.

import google.protobuf.reflection
from google.protobuf.message_factory import MessageFactory
import logging
import zmq
import zmq.utils.z85
Expand Down Expand Up @@ -197,11 +197,12 @@ def recv(self, a_timeout=1000):
if frame_values[0] > 0:
# Create message by parsing content
data = self._socket.recv(0)
reply = google.protobuf.reflection.ParseMessage(desc, data)
reply = MessageFactory().GetMessageClass(desc)()
reply.ParseFromString(data)
else:
# No content, just create message instance
data = self._socket.recv(0)
reply = google.protobuf.reflection.MakeClass(desc)()
reply = MessageFactory().GetMessageClass(desc)()

return reply, desc.name, frame_values[3]
else:
Expand Down Expand Up @@ -271,8 +272,6 @@ def reset(self):
def makeMessage(self, msg_name):
# find message descriptor based on type (descriptor index)
if msg_name in self._msg_desc_by_name:
return google.protobuf.reflection.MakeClass(
self._msg_desc_by_name[msg_name]
)()
return MessageFactory().GetMessageClass(self._msg_desc_by_name[msg_name])()
else:
return None

0 comments on commit 5c70a5e

Please sign in to comment.