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

Do not enable seeder signal handlers in tests #16079

Merged
merged 1 commit into from
Aug 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
6 changes: 3 additions & 3 deletions chia/seeder/dns_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import signal
import sys
import traceback
from asyncio import AbstractEventLoop
from contextlib import asynccontextmanager
from dataclasses import dataclass, field
from ipaddress import IPv4Address, IPv6Address, ip_address
Expand Down Expand Up @@ -322,7 +321,6 @@ async def run(self) -> AsyncIterator[None]:
log.info("Starting DNS server.")
# Get a reference to the event loop as we plan to use low-level APIs.
loop = asyncio.get_running_loop()
await self.setup_signal_handlers(loop)

# Set up the crawl store and the peer update task.
self.crawl_store = await CrawlStore.create(await aiosqlite.connect(self.db_path, timeout=120))
Expand Down Expand Up @@ -356,8 +354,9 @@ async def run(self) -> AsyncIterator[None]:
await self.stop()
log.info("DNS server stopped.")

async def setup_signal_handlers(self, loop: AbstractEventLoop) -> None:
async def setup_process_global_state(self) -> None:
try:
loop = asyncio.get_running_loop()
loop.add_signal_handler(signal.SIGINT, self._accept_signal)
loop.add_signal_handler(signal.SIGTERM, self._accept_signal)
except NotImplementedError:
Expand Down Expand Up @@ -508,6 +507,7 @@ async def dns_response(self, request: DNSRecord) -> DNSRecord:


async def run_dns_server(dns_server: DNSServer) -> None: # pragma: no cover
await dns_server.setup_process_global_state()
async with dns_server.run():
await dns_server.shutdown_event.wait() # this is released on SIGINT or SIGTERM or any unhandled exception

Expand Down