fix: ensure global diagram context is cleared if rendering fails

pull/1203/head
Carlos Barbero 8 months ago
parent adb8661cb7
commit 4eb914f264

@ -205,7 +205,10 @@ class Diagram:
return self return self
def __exit__(self, exc_type, exc_value, traceback): def __exit__(self, exc_type, exc_value, traceback):
try:
self.render() self.render()
finally:
if os.path.exists(self.filename):
# Remove the graphviz file leaving only the image. # Remove the graphviz file leaving only the image.
os.remove(self.filename) os.remove(self.filename)
setdiagram(None) setdiagram(None)

Loading…
Cancel
Save