python: Accept Optional[FrameType] in signal handlers.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-12-22 21:53:42 -08:00
committed by Tim Abbott
parent 7a9074ecfd
commit 702ce071f4
3 changed files with 9 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ import threading
from argparse import ArgumentParser
from contextlib import contextmanager
from types import FrameType
from typing import Any, Iterator, List
from typing import Any, Iterator, List, Optional
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
@@ -53,7 +53,7 @@ class Command(BaseCommand):
logging.basicConfig()
logger = logging.getLogger("process_queue")
def exit_with_three(signal: int, frame: FrameType) -> None:
def exit_with_three(signal: int, frame: Optional[FrameType]) -> None:
"""
This process is watched by Django's autoreload, so exiting
with status code 3 will cause this process to restart.
@@ -91,7 +91,7 @@ class Command(BaseCommand):
queue_name = options["queue_name"]
worker_num = options["worker_num"]
def signal_handler(signal: int, frame: FrameType) -> None:
def signal_handler(signal: int, frame: Optional[FrameType]) -> None:
logger.info("Worker %d disconnecting from queue %s", worker_num, queue_name)
worker.stop()
sys.exit(0)