Skip to content
Snippets Groups Projects
Commit 40bc4404 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

+hang until sig

parent 51251604
No related branches found
No related tags found
No related merge requests found
...@@ -4,13 +4,9 @@ import six ...@@ -4,13 +4,9 @@ import six
import logging import logging
import warnings import warnings
from satella.coding import Monitor, typed from satella.coding import Monitor, typed
from .metrics import Metric from .metrics import Metric, DISABLED, RUNTIME, DEBUG
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# Detail levels
DISABLED = 0
RUNTIME = 1
DEBUG = 2
......
...@@ -9,6 +9,10 @@ logger = logging.getLogger(__name__) ...@@ -9,6 +9,10 @@ logger = logging.getLogger(__name__)
from satella.coding import typed from satella.coding import typed
# Detail levels
DISABLED = 0
RUNTIME = 1
DEBUG = 2
class Metric(object): class Metric(object):
""" """
......
...@@ -27,6 +27,7 @@ def hang_until_sig(extra_signals=[]): ...@@ -27,6 +27,7 @@ def hang_until_sig(extra_signals=[]):
else: else:
logger.warning('Received signal %s', sigq) logger.warning('Received signal %s', sigq)
me_lock.release() me_lock.release()
return o
for s in extra_signals + [signal.SIGTERM, signal.SIGINT]: for s in extra_signals + [signal.SIGTERM, signal.SIGINT]:
signal.signal(s, insignum(s)) signal.signal(s, insignum(s))
...@@ -34,5 +35,6 @@ def hang_until_sig(extra_signals=[]): ...@@ -34,5 +35,6 @@ def hang_until_sig(extra_signals=[]):
while True: while True:
try: try:
me_lock.acquire() me_lock.acquire()
return
except InterruptedError: except InterruptedError:
pass pass
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
setup(name='satella', setup(name='satella',
version='2.0.2a1', version='2.0.3',
description=u'Utilities for writing servers in Python', description=u'Utilities for writing servers in Python',
author=u'Piotr Maślanka', author=u'Piotr Maślanka',
author_email='piotrm@smok.co', author_email='piotrm@smok.co',
......
...@@ -2,12 +2,34 @@ ...@@ -2,12 +2,34 @@
from __future__ import print_function, absolute_import, division from __future__ import print_function, absolute_import, division
import sys import sys
import six
import unittest import unittest
import time
import threading
from mock import patch, Mock from mock import patch, Mock
import os import os
class TestHUS(unittest.TestCase):
@patch('signal.signal')
def test_signal(self, signal):
class Delayer(threading.Thread):
def run(self):
time.sleep(2)
for signame, handler in signal.call_args_list:
print(handler)
handler(signame, None)
from satella.posix import hang_until_sig
#Delayer().start()
hang_until_sig()
print(signal.call_args_list)
class TestPidlock(unittest.TestCase): class TestPidlock(unittest.TestCase):
def test_pidlock(self): def test_pidlock(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment