Skip to content

Commit

Permalink
Merge d4ecb73 into 648adfe
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineCezar committed Mar 11, 2018
2 parents 648adfe + d4ecb73 commit 6a3dba0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion AUTHORS.rst
Expand Up @@ -10,4 +10,4 @@ Development Lead
Contributors
------------

None yet. Why not be the first?
* Bryce Guinta
5 changes: 5 additions & 0 deletions HISTORY.rst
Expand Up @@ -3,6 +3,11 @@
History
-------

1.2.0 (2018-03-11)
------------------

* Allow sub-second timeout

1.1.1 (2016-09-05)
------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -24,7 +24,7 @@

setup(
name='timeoutcontext',
version='1.1.1',
version='1.2.0',
description="A signal based timeout context manager",
long_description=readme + '\n\n' + history,
author="Antoine Cezar",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_timeout.py
Expand Up @@ -73,7 +73,7 @@ def test_it_does_not_replace_alarm_handler_when_seconds_is_zero(self, signal_moc
@patch('timeoutcontext._timeout.signal')
def test_it_does_not_set_alarm_when_seconds_is_zero(self, signal_mock):
with timeout(0):
signal_mock.alarm.assert_not_called()
signal_mock.setitimer.assert_not_called()

@patch('timeoutcontext._timeout.signal')
def test_it_does_not_restore_alarm_handler_when_seconds_is_zero(self, signal_mock):
Expand All @@ -91,7 +91,7 @@ def test_it_replace_alarm_handler_on_enter(self, signal_mock):
@patch('timeoutcontext._timeout.signal')
def test_it_request_alarm_to_be_sent_in_given_seconds_on_enter(self, signal_mock):
with timeout(2):
signal_mock.alarm.assert_called_with(2)
signal_mock.setitimer.assert_called_with(signal_mock.ITIMER_REAL, 2)

@patch('timeoutcontext._timeout.signal')
def test_it_restore_alarm_handler_on_exit(self, signal_mock):
Expand Down
2 changes: 1 addition & 1 deletion timeoutcontext/_timeout.py
Expand Up @@ -62,7 +62,7 @@ def __init__(self, seconds):
def __enter__(self):
if self._seconds:
self._replace_alarm_handler()
signal.alarm(self._seconds)
signal.setitimer(signal.ITIMER_REAL, self._seconds)
return self

def __exit__(self, exc_type, exc_value, traceback):
Expand Down

0 comments on commit 6a3dba0

Please sign in to comment.