Skip to content

Commit d1a8847

Browse files
committed
v1.3.10
-------- 2022-04-26: add tests for thread lock
1 parent 342f6dd commit d1a8847

File tree

9 files changed

+93
-12
lines changed

9 files changed

+93
-12
lines changed

.docs/README_template.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ wrapt_timeout_decorator
22
=======================
33

44

5-
Version v1.3.9 as of 2022-04-26 see `Changelog`_
5+
Version v1.3.10 as of 2022-04-26 see `Changelog`_
66

77

88
.. include:: ./badges.rst

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
v1.3.10
5+
--------
6+
2022-04-26: add tests for thread lock
7+
48
v1.3.9
59
--------
610
2022-04-26: preserve Signature of the decorator

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ wrapt_timeout_decorator
22
=======================
33

44

5-
Version v1.3.9 as of 2022-04-26 see `Changelog`_
5+
Version v1.3.10 as of 2022-04-26 see `Changelog`_
66

77
|build_badge| |license| |jupyter| |pypi| |pypi-downloads| |black|
88

@@ -848,6 +848,10 @@ This software is licensed under the `MIT license <http://en.wikipedia.org/wiki/M
848848
Changelog
849849
=========
850850

851+
v1.3.10
852+
--------
853+
2022-04-26: add tests for thread lock
854+
851855
v1.3.9
852856
--------
853857
2022-04-26: preserve Signature of the decorator

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def get_line_data(line: str) -> str:
8484

8585
setup_kwargs: Dict[str, Any] = dict()
8686
setup_kwargs["name"] = "wrapt_timeout_decorator"
87-
setup_kwargs["version"] = "v1.3.9"
87+
setup_kwargs["version"] = "v1.3.10"
8888
setup_kwargs["url"] = "https://github.com/bitranox/wrapt_timeout_decorator"
8989
setup_kwargs["packages"] = find_packages()
9090
setup_kwargs["package_data"] = {"wrapt_timeout_decorator": ["py.typed", "*.pyi", "__init__.pyi"]}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
own_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit && pwd -P )" # this gives the full path, even for sourced scripts
3+
4+
# shellcheck disable=SC2050
5+
if [[ "True" != "True" ]]; then
6+
echo "exit - ${BASH_SOURCE[0]} is not configured by PizzaCutter"
7+
exit 0
8+
fi
9+
10+
# shellcheck disable=SC1090
11+
source "${own_dir}/lib_bash_functions.sh"
12+
project_root_dir="${project_root_dir}"
13+
DO_FLAKE8_TESTS="True"
14+
DO_MYPY_TESTS="True"
15+
DO_PYTEST="True"
16+
DO_BLACK="True"
17+
# cleanup on cntrl-c
18+
trap cleanup EXIT
19+
20+
# install dependencies
21+
install_dependencies
22+
23+
function pytest_loop {
24+
while true; do
25+
banner "Project Root Dir: ${project_root_dir}"
26+
cleanup
27+
28+
if [ "${DO_BLACK}" == "True" ]; then
29+
if ! run_black; then continue; fi
30+
fi
31+
32+
# we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins
33+
if [ "${DO_FLAKE8_TESTS}" == "True" ]; then
34+
if ! run_flake8_tests; then continue; fi
35+
fi
36+
37+
if [ "${DO_PYTEST}" == "True" ]; then
38+
if ! run_pytest --disable-warnings; then continue; fi
39+
fi
40+
41+
# we prefer to run tests on its own, not within pytest, due to shaky and outdated pytest plugins
42+
if [ "${DO_MYPY_TESTS}" == "True" ]; then
43+
if ! run_mypy_tests; then continue; fi
44+
fi
45+
46+
# if ! install_pip_requirements_venv; then continue; fi
47+
# if ! setup_test_venv; then continue; fi
48+
# if ! setup_install_venv; then continue; fi
49+
if ! test_commandline_interface_venv; then continue; fi
50+
51+
banner "ALL TESTS PASSED for ${project_root_dir}"
52+
banner "ALL TESTS PASSED for ${project_root_dir}"
53+
banner "ALL TESTS PASSED for ${project_root_dir}"
54+
sleep 5
55+
done
56+
57+
}
58+
59+
# upgrade_pytest
60+
# upgrade_mypy
61+
pytest_loop

tests/test_wrapt_timeout_decorator.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Timeout decorator tests."""
22
# STDLIB
33
import sys
4+
import threading
45
from threading import Thread
56
import time
67
from typing import Any
@@ -30,6 +31,17 @@ def f() -> None:
3031
f()
3132

3233

34+
def test_timeout_decorator_thread_lock(use_signals: bool) -> None:
35+
@timeout(0.2, use_signals=use_signals) # type: ignore
36+
def f() -> None:
37+
my_lock = threading.Lock()
38+
my_lock.acquire()
39+
my_lock.acquire()
40+
41+
with pytest.raises(TimeoutError):
42+
f()
43+
44+
3345
def test_timeout_class_method(use_signals: bool) -> None:
3446
with pytest.raises(TimeoutError, match=r"Function f timed out after 0\.3 seconds"):
3547
ClassTest1().f(use_signals=use_signals)

wrapt_timeout_decorator/__init__conf__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
name = "wrapt_timeout_decorator"
44
title = "The better timout decorator"
5-
version = "v1.3.9"
5+
version = "v1.3.10"
66
url = "https://github.com/bitranox/wrapt_timeout_decorator"
77
author = "Robert Nowotny"
88
author_email = "bitranox@gmail.com"
@@ -17,7 +17,7 @@ def print_info() -> None:
1717
1818
The better timout decorator
1919
20-
Version : v1.3.9
20+
Version : v1.3.10
2121
Url : https://github.com/bitranox/wrapt_timeout_decorator
2222
Author : Robert Nowotny
2323
Email : bitranox@gmail.com"""

wrapt_timeout_decorator/wrap_helper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from typing import Any, Callable, Dict, List, Type, Union, Optional
99

1010
# EXT
11-
import dill # type: ignore
12-
import multiprocess # type: ignore
11+
import dill
12+
import multiprocess
1313

1414
# Types
1515
AlarmHandler = Union[Callable[[int, Optional[FrameType]], Any], int, signal.Handlers, None]
@@ -42,7 +42,7 @@ def __init__(
4242
self.args = args
4343
self.kwargs = kwargs
4444

45-
self.dec_timeout_float = 0.0 # type: float
45+
self.dec_timeout_float: float = 0.0
4646
self.old_alarm_handler: AlarmHandler = None
4747
self.child_conn: "multiprocess.Pipe" = None
4848

@@ -120,7 +120,7 @@ def detect_unpickable_objects_and_reraise(object_to_pickle: Any) -> None:
120120
def detect_unpickable_objects(object_to_pickle: Any, dill_trace: bool = True, log_warning: bool = True) -> Dict[str, Union[str, List[Any]]]:
121121
if log_warning:
122122
logger.warning('always remember that the "object_to_pickle" should not be defined within the main context')
123-
dict_result = dict() # type: Dict[str, Union[str, List[Any]]]
123+
dict_result: Dict[str, Union[str, List[Any]]] = dict()
124124
dict_result["object_name"] = ""
125125
dict_result["bad_items"] = list()
126126
dict_result["bad_objects"] = list()
@@ -150,7 +150,7 @@ def get_object_name(object_to_pickle: object) -> str:
150150

151151

152152
def get_bad_pickling_types(object_to_pickle: object) -> List[Any]:
153-
bad_types = list() # type: List[Any]
153+
bad_types: List[Any] = list()
154154
# noinspection PyBroadException
155155
try:
156156
bad_types = dill.detect.badtypes(object_to_pickle)
@@ -161,7 +161,7 @@ def get_bad_pickling_types(object_to_pickle: object) -> List[Any]:
161161

162162

163163
def get_bad_pickling_objects(object_to_pickle: Any) -> Any:
164-
bad_objects = list() # type: List[object]
164+
bad_objects: List[object] = list()
165165
# noinspection PyBroadException
166166
try:
167167
bad_objects = dill.detect.badobjects(object_to_pickle)

wrapt_timeout_decorator/wrapt_timeout_decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Any, Callable, Type, TypeVar, Union
1010

1111
# EXT
12-
from dill import PicklingError # type: ignore
12+
from dill import PicklingError
1313
import wrapt
1414

1515
# OWN

0 commit comments

Comments
 (0)