Skip to content

Commit a44aad2

Browse files
committed
prefer CommandError
1 parent 628b646 commit a44aad2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/common/core/management/commands/waitfordb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from argparse import ArgumentParser
44
from typing import Any
55

6-
from django.core.management import BaseCommand
6+
from django.core.management import BaseCommand, CommandError
77
from django.db import OperationalError, connections
88
from django.db.migrations.executor import MigrationExecutor
99

@@ -54,7 +54,7 @@ def handle(
5454
if time.monotonic() - start > wait_for:
5555
msg = f"Failed to connect to DB within {wait_for} seconds."
5656
logger.error(msg)
57-
exit(msg)
57+
raise CommandError(msg)
5858

5959
conn = connections.create_connection(database)
6060
try:
@@ -75,7 +75,7 @@ def handle(
7575
if time.monotonic() - start > wait_for:
7676
msg = f"Didn't detect applied migrations for {wait_for} seconds."
7777
logger.error(msg)
78-
exit(msg)
78+
raise CommandError(msg)
7979

8080
conn = connections[database]
8181
executor = MigrationExecutor(conn)

0 commit comments

Comments
 (0)