Skip to content

Fix windows file lock issue by using delete=False with temp file #300

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions llmstack/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,16 @@ def print_compose_logs(follow=True, stream=True):

def start(llmstack_environment):
# Create a temp file with this environment variables to be used by docker-compose
with tempfile.NamedTemporaryFile(mode="w") as f:
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
for key in llmstack_environment:
f.write(f"{key}={llmstack_environment[key]}\n")
f.flush()
env_file_path = f.name

try:
# Start the containers
docker_client = DockerClient(
compose_files=[os.path.join(os.path.dirname(__file__), "docker-compose.yml")],
compose_env_file=f.name,
compose_env_file=env_file_path,
)

# Start the containers
Expand Down Expand Up @@ -240,6 +241,9 @@ def start(llmstack_environment):

print("\n".join(compose_output[-10:]), end="", flush=True)
last_output_len = len(compose_output[-10:])
finally:
# File clean up
os.remove(env_file_path)


def main():
Expand Down