2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 22:35:15 +00:00

python tests: Implemented signal.alarm for Windows

signal.alarm is not available in Windows and would trigger an exception
when called. Implemented this to mentain compatibility between
Windows and Linux for python tests.

Signed-off-by: Paul-Daniel Boca <pboca@cloudbasesolutions.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
This commit is contained in:
Paul Boca
2016-08-02 17:45:39 +00:00
committed by Gurucharan Shetty
parent 922247c684
commit 36d516346a
4 changed files with 29 additions and 5 deletions

View File

@@ -15,6 +15,7 @@
import atexit
import os
import signal
import sys
import ovs.vlog
@@ -134,3 +135,25 @@ def _init():
if signal.getsignal(signr) == signal.SIG_DFL:
signal.signal(signr, _signal_handler)
atexit.register(_atexit_handler)
def signal_alarm(timeout):
if sys.platform == "win32":
import os
import time
import threading
class Alarm (threading.Thread):
def __init__(self, timeout):
super(Alarm, self).__init__()
self.timeout = timeout
self.setDaemon(True)
def run(self):
time.sleep(self.timeout)
os._exit(1)
alarm = Alarm(timeout)
alarm.start()
else:
signal.alarm(timeout)