mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
python: Accept Optional[FrameType] in signal handlers.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
7a9074ecfd
commit
702ce071f4
@@ -5,6 +5,7 @@ import subprocess
|
||||
import sys
|
||||
import time
|
||||
import types
|
||||
from typing import Optional
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
|
||||
@@ -22,7 +23,7 @@ def check_worker_launch(run_dev: "subprocess.Popen[str]") -> bool:
|
||||
failed = False
|
||||
i = 0
|
||||
|
||||
def on_timer(signum: int, frame: types.FrameType) -> None:
|
||||
def on_timer(signum: int, frame: Optional[types.FrameType]) -> None:
|
||||
nonlocal failed, i
|
||||
sys.stdout.write(".")
|
||||
sys.stdout.flush()
|
||||
|
||||
@@ -20,10 +20,11 @@ logger = logging.getLogger("zulip.debug")
|
||||
# (that link also points to code for an interactive remote debugger
|
||||
# setup, which we might want if we move Tornado to run in a daemon
|
||||
# rather than via screen).
|
||||
def interactive_debug(sig: int, frame: FrameType) -> None:
|
||||
def interactive_debug(sig: int, frame: Optional[FrameType]) -> None:
|
||||
"""Interrupt running process, and provide a python prompt for
|
||||
interactive debugging."""
|
||||
d = {"_frame": frame} # Allow access to frame object.
|
||||
if frame is not None:
|
||||
d.update(frame.f_globals) # Unless shadowed by global
|
||||
d.update(frame.f_locals)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user