Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run_middleware_hook("post_process_message")
return
try:
res = self._subscription(data, **dict(message.attributes))
except Exception as e:
run_middleware_hook(
"post_process_message_failure",
self._subscription,
e,
start_time,
message,
)
else:
message.ack()
run_middleware_hook(
"post_process_message_success", self._subscription, start_time, message,
)
return res
finally:
run_middleware_hook("post_process_message")
def __call__(self, message):
run_middleware_hook("pre_process_message", self._subscription, message)
start_time = time.time()
try:
data = json.loads(message.data.decode("utf-8"))
except json.JSONDecodeError as e:
message.ack()
run_middleware_hook(
"post_process_message_failure",
self._subscription,
e,
start_time,
message,
)
run_middleware_hook("post_process_message")
return
try:
res = self._subscription(data, **dict(message.attributes))
except Exception as e:
run_middleware_hook(
"post_process_message_failure",
self._subscription,
e,
start_time,
message,
)
else:
message.ack()
run_middleware_hook(
"post_process_message_success", self._subscription, start_time, message,
def __call__(self, message):
run_middleware_hook("pre_process_message", self._subscription, message)
start_time = time.time()
try:
data = json.loads(message.data.decode("utf-8"))
except json.JSONDecodeError as e:
message.ack()
run_middleware_hook(
"post_process_message_failure",
self._subscription,
e,
start_time,
message,
)
run_middleware_hook("post_process_message")
return
try:
res = self._subscription(data, **dict(message.attributes))
except Exception as e:
run_middleware_hook(
"post_process_message_failure",
self._subscription,
e,
attrs["published_at"] = str(time.time())
run_middleware_hook("pre_publish", topic, data, attrs)
payload = json.dumps(data, cls=self._encoder).encode("utf-8")
topic_path = self._client.topic_path(self._gc_project_id, topic)
future = self._client.publish(topic_path, payload, **attrs)
if not blocking:
return future
try:
future.result(timeout=timeout or self._timeout)
except TimeoutError as e:
run_middleware_hook("post_publish_failure", topic, e, data)
if raise_exception:
raise e
else:
run_middleware_hook("post_publish", topic)
return future
def __call__(self, message):
run_middleware_hook("pre_process_message", self._subscription, message)
start_time = time.time()
try:
data = json.loads(message.data.decode("utf-8"))
except json.JSONDecodeError as e:
message.ack()
run_middleware_hook(
"post_process_message_failure",
self._subscription,
e,
start_time,
message,
)
run_middleware_hook("post_process_message")
return