Merge "Skips signal handling on Windows" into stable/rocky

This commit is contained in:
Zuul 2018-08-28 12:04:32 +00:00 committed by Gerrit Code Review
commit 67a8a8c7f5
2 changed files with 15 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import io
import logging
import os
import random
import select
import signal
import six
import sys
@ -203,7 +204,8 @@ class SignalHandler(object):
For Python 3.5 and later, deal with the changes in PEP 475 that prevent
a signal from interrupting eventlet's call to poll() or sleep().
"""
self.__force_interrupt_on_signal = sys.version_info >= (3, 5)
self.__force_interrupt_on_signal = (sys.version_info >= (3, 5) and
hasattr(select, 'poll'))
if self.__force_interrupt_on_signal:
try:

View File

@ -477,6 +477,18 @@ class ProcessLauncherTest(base.ServiceBaseTestCase):
m.assert_called_once_with(signal.SIGTERM, 'test')
signal_handler.clear()
@mock.patch('sys.version_info', (3, 5))
@mock.patch.object(service, 'select', spec=[])
def test_setup_signal_interruption_no_select_poll(self, mock_select):
# NOTE(claudiub): SignalHandler is a singleton, which means that it
# might already be initialized. We need to clear to clear the cache
# in order to prevent race conditions between tests.
service.SignalHandler.__class__._instances.clear()
signal_handler = service.SignalHandler()
self.addCleanup(service.SignalHandler.__class__._instances.clear)
self.assertFalse(
signal_handler._SignalHandler__force_interrupt_on_signal)
@mock.patch('signal.alarm')
@mock.patch("os.kill")
@mock.patch("oslo_service.service.ProcessLauncher.stop")