Skip to content

Commit 6898877

Browse files
committed
make test script compatible with python 3.8
1 parent 1a3f429 commit 6898877

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lambda_multiprocessing/test_main.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@
55
from typing import Tuple, Optional
66
from pathlib import Path
77
import os
8-
from functools import cache
8+
import sys
9+
910

1011
import boto3
1112
from moto import mock_aws
1213
from lambda_multiprocessing.timeout import TimeoutManager, TestTimeoutException
1314

15+
if sys.version_info < (3, 9):
16+
# functools.cache was added in 3.9
17+
# define an empty decorator that doesn't do anything
18+
# (our usage of the cache isn't essential)
19+
def cache(func):
20+
return func
21+
else:
22+
# Import the cache function from functools for Python 3.9 and above
23+
from functools import cache
24+
1425
# add an overhead for duration when asserting the duration of child processes
1526
# if other processes are hogging CPU, make this bigger
1627
delta = 0.1
@@ -39,7 +50,7 @@ def return_with_sleep(x, delay=0.3):
3950

4051
def _raise(ex: Optional[Exception]):
4152
if ex:
42-
raise exfrom .timeout
53+
raise ex
4354

4455
class ExceptionA(Exception):
4556
pass

0 commit comments

Comments
 (0)