Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reflex hosting] clean up tmp dir for storing zip archives #2021

Merged
merged 1 commit into from
Oct 24, 2023
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
Loading