I am publishing to topics using Python pubsub client, and there is a cloud function set up that is triggered by pubsub messages. I can trigger the function properly and generate the desired return value but I cant figure to return that value to publisher/client side. Thanks everyone!
client code:
def call_getTime():
message_future = publisher.publish(topic_path,
data=data,
)
message_future.add_done_callback(callback)
print(message_future.result())
def callback(message_future):
if message_future.exception(timeout=30):
print('Publishing message threw an Exception {}.'.format(
message_future.exception()))
else:
print(message_future.result())
Cloud Function:
def getTime(data, context):
r = {'time': time.time()}
return flask.jsonify(r)