Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion reflex/reflex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import contextlib
import json
import os
import shutil
import tempfile
import time
from datetime import datetime
Expand Down Expand Up @@ -560,8 +561,8 @@ def deploy(
# Compile the app in production mode.
config.api_url = api_url
config.deploy_url = deploy_url
tmp_dir = tempfile.mkdtemp()
try:
tmp_dir = tempfile.mkdtemp()
export(
frontend=True,
backend=True,
Expand All @@ -574,6 +575,9 @@ def deploy(
f"Encountered ImportError, did you install all the dependencies? {ie}"
)
raise typer.Exit(1) from ie
finally:
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)

frontend_file_name = constants.ComponentName.FRONTEND.zip()
backend_file_name = constants.ComponentName.BACKEND.zip()
Expand Down Expand Up @@ -601,6 +605,9 @@ def deploy(
except Exception as ex:
console.error(f"Unable to deploy due to: {ex}")
raise typer.Exit(1) from ex
finally:
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)

# Deployment will actually start when data plane reconciles this request
console.debug(f"deploy_response: {deploy_response}")
Expand Down