Skips signal handling on Windows
Setting up signal handling fails on Windows due to missing select
module attributes. This patch skips the setup on Windows.
Change-Id: I75db453ec907efb01e1bb411690dadd92a48314d
Closes-Bug: #1788022
(cherry picked from commit 2ee3894f49
)
This commit is contained in:
parent
28cd4419d3
commit
c8c8946d32
@ -28,6 +28,7 @@ import io
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import select
|
||||||
import signal
|
import signal
|
||||||
import six
|
import six
|
||||||
import sys
|
import sys
|
||||||
@ -203,7 +204,8 @@ class SignalHandler(object):
|
|||||||
For Python 3.5 and later, deal with the changes in PEP 475 that prevent
|
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().
|
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:
|
if self.__force_interrupt_on_signal:
|
||||||
try:
|
try:
|
||||||
|
@ -477,6 +477,18 @@ class ProcessLauncherTest(base.ServiceBaseTestCase):
|
|||||||
m.assert_called_once_with(signal.SIGTERM, 'test')
|
m.assert_called_once_with(signal.SIGTERM, 'test')
|
||||||
signal_handler.clear()
|
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('signal.alarm')
|
||||||
@mock.patch("os.kill")
|
@mock.patch("os.kill")
|
||||||
@mock.patch("oslo_service.service.ProcessLauncher.stop")
|
@mock.patch("oslo_service.service.ProcessLauncher.stop")
|
||||||
|
Loading…
Reference in New Issue
Block a user