From e3df0b9c0872719bed826b827f8afc550671b532 Mon Sep 17 00:00:00 2001 From: Patrick Udomsirirat Date: Tue, 25 May 2021 23:06:39 +0000 Subject: [PATCH] Account for soft-deleted subjects (#1127) --- .../schema_registry/schema_registry_client.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/confluent_kafka/schema_registry/schema_registry_client.py b/src/confluent_kafka/schema_registry/schema_registry_client.py index 2e40131ac..b03610c6c 100644 --- a/src/confluent_kafka/schema_registry/schema_registry_client.py +++ b/src/confluent_kafka/schema_registry/schema_registry_client.py @@ -458,12 +458,16 @@ def delete_subject(self, subject_name, permanent=False): `DELETE Subject API Reference `_ """ # noqa: E501 - list = self._rest_client.delete('subjects/{}' - .format(_urlencode(subject_name))) + try: + list = self._rest_client.delete('subjects/{}' + .format(_urlencode(subject_name))) + except SchemaRegistryError as e: + if e.error_code != 40404: + raise if permanent: - self._rest_client.delete('subjects/{}?permanent=true' - .format(_urlencode(subject_name))) + list = self._rest_client.delete('subjects/{}?permanent=true' + .format(_urlencode(subject_name))) return list