GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Fix ValueError in signal handling for Trino worker threads by mbm-codes · Pull Request #6428 · feast-dev/feast

fix: Fix ValueError in signal handling for Trino worker threads #6428

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.

Sign up for GitHub

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

Merged
ntkathole merged 4 commits into feast-dev:master from mbm-codes:fix/trino-signal-worker-thread
Jul 1, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix: Fix ValueError in signal handling for Trino worker threads #6428

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
9776761
fix: fix signal.signal() ValueError in Trino worker threads
mbm-codes May 21, 2026
c5ca3f8
test: patch signal.signal in main thread test to avoid handler leak
mbm-codes Jun 1, 2026
d9d3fab
Update sdk/python/feast/infra/offline_stores/contrib/trino_offline_st…
mbm-codes Jun 3, 2026
4c1e5d8
test: address PR feedback for worker thread errors and signals
mbm-codes Jun 3, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

48 changes: 48 additions & 0 deletions 48 ...python/feast/infra/offline_stores/contrib/trino_offline_store/tests/test_trino_queries.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import signal
import threading
from unittest.mock import MagicMock, patch

from feast.infra.offline_stores.contrib.trino_offline_store.trino_queries import (
Query,
)


def test_query_init_in_main_thread_registers_signals():
"""signal.signal() should work fine in main thread."""

# Should not raise any exception in main thread
cursor = MagicMock()

with patch("signal.signal") as mock_signal:
query = Query(query_text="SELECT 1", cursor=cursor)
assert query.query_text == "SELECT 1"

# Verify signal handlers are registered correctly
mock_signal.assert_any_call(signal.SIGINT, query.cancel)
mock_signal.assert_any_call(signal.SIGTERM, query.cancel)

# Expected signal.signal to be called twice for SIGINT and SIGTERM
assert mock_signal.call_count == 2


def test_query_init_in_worker_thread_does_not_raise():
"""Regression test: signal.signal() fails in non-main threads."""
# signal.signal() raises ValueError when called outside the main thread.
# This test verifies the fix guards against that by running Query.__init__
# in a worker thread and ensuring no exception is raised.

errors = []
cursor = MagicMock()

def create_query():
try:
query = Query(query_text="SELECT 1", cursor=cursor)
assert query.query_text == "SELECT 1"
except ValueError as e:
errors.append(e)

thread = threading.Thread(target=create_query)
thread.start()
thread.join()

assert not errors, f"Unexpected ValueError in worker thread: {errors}"
6 changes: 4 additions & 2 deletions 6 sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/trino_queries.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import signal
import threading
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, List, Optional
Expand Down Expand Up @@ -92,8 +93,9 @@ def __init__(self, query_text: str, cursor: Cursor):
self.status = QueryStatus.PENDING
self._cursor = cursor

signal.signal(signal.SIGINT, self.cancel)
signal.signal(signal.SIGTERM, self.cancel)
if threading.current_thread() is threading.main_thread():
signal.signal(signal.SIGINT, self.cancel)
signal.signal(signal.SIGTERM, self.cancel)

def execute(self) -> Results:
try:
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.