Skip to content

Commit fa06088

Browse files
committed
temp deprecated replacement file for tests
1 parent ebfa152 commit fa06088

File tree

5 files changed

+86
-4
lines changed

5 files changed

+86
-4
lines changed

awsiot/iotidentity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import json
1010
import typing
1111

12-
from awscrt.common import deprecated
12+
from awsiot.remove_me import deprecated
13+
# from awscrt.common import deprecated
1314

1415
@deprecated(
1516
"""

awsiot/iotjobs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import typing
1212
import uuid
1313

14-
from awscrt.common import deprecated
14+
from awsiot.remove_me import deprecated
15+
# from awscrt.common import deprecated
1516

1617
@deprecated(
1718
"""

awsiot/iotshadow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import typing
1212
import uuid
1313

14-
from awscrt.common import deprecated
14+
from awsiot.remove_me import deprecated
15+
# from awscrt.common import deprecated
1516

1617
@deprecated(
1718
"""

awsiot/mqtt_connection_builder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@
124124
import awscrt.io
125125
import awscrt.mqtt
126126
import urllib.parse
127-
from awscrt.common import deprecated
127+
# from awscrt.common import deprecated
128+
from remove_me import deprecated
128129

129130

130131
def _check_required_kwargs(**kwargs):

awsiot/remove_me.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# TEMPORARY WIP FILE TO USE IN PLACE OF NON-ACCESSIBLE common.py from awscrt until a version is cut.
2+
# DELETE THIS FILE and point to the correct location after crt has released a version with soft deprecation
3+
4+
"""
5+
Cross-platform library for `awscrt`.
6+
"""
7+
from typing import TYPE_CHECKING
8+
import _awscrt
9+
10+
__all__ = [
11+
"get_cpu_group_count",
12+
"get_cpu_count_for_group",
13+
"join_all_native_threads",
14+
"deprecated",
15+
]
16+
17+
# At type-check time, expose a real symbol so linters/IDEs understand it.
18+
# At runtime, prefer typing_extensions; fall back to typing (Py3.13+); else no-op.
19+
if TYPE_CHECKING:
20+
# Static analysers will always attempt to import deprecated from typing_extensions and
21+
# fall back to known interpretation of `deprecated` if it fails and appropriately handle
22+
# the `@deprecated` tags.
23+
from typing_extensions import deprecated as deprecated
24+
else:
25+
_deprecated_impl = None
26+
try:
27+
# preferred import of deprecated
28+
from typing_extensions import deprecated as _deprecated_impl
29+
except Exception:
30+
try:
31+
from typing import deprecated as _deprecated_impl # Python 3.13+
32+
except Exception:
33+
_deprecated_impl = None
34+
35+
def deprecated(msg=None, *, since=None):
36+
if _deprecated_impl is None:
37+
def _noop(obj): return obj
38+
return _noop
39+
if since is not None:
40+
try:
41+
return _deprecated_impl(msg, since=since)
42+
except TypeError:
43+
# older typing_extensions doesn't support the 'since' kwarg
44+
pass
45+
return _deprecated_impl(msg)
46+
47+
48+
def get_cpu_group_count() -> int:
49+
"""
50+
Returns number of processor groups on the system.
51+
52+
Useful for working with non-uniform memory access (NUMA) nodes.
53+
"""
54+
return _awscrt.get_cpu_group_count()
55+
56+
57+
def get_cpu_count_for_group(group_idx: int) -> int:
58+
"""
59+
Returns number of processors in a given group.
60+
"""
61+
return _awscrt.get_cpu_count_for_group(group_idx)
62+
63+
64+
def join_all_native_threads(*, timeout_sec: float = -1.0) -> bool:
65+
"""
66+
Waits for all native threads to complete their join call.
67+
68+
This can only be safely called from the main thread.
69+
This call may be required for native memory usage to reach zero.
70+
71+
Args:
72+
timeout_sec (float): Number of seconds to wait before a timeout exception is raised.
73+
By default the wait is unbounded.
74+
75+
Returns:
76+
bool: Returns whether threads could be joined before the timeout.
77+
"""
78+
return _awscrt.thread_join_all_managed(timeout_sec)

0 commit comments

Comments
 (0)