Skip to content

Commit b2c03b2

Browse files
Make can importable without wrapt
1 parent 1bdfc56 commit b2c03b2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎can/thread_safe_bus.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
from abc import ABCMeta
1010
from threading import RLock
1111

12-
from wrapt import ObjectProxy
12+
try:
13+
# Only raise an exception on instantiation but allow module
14+
# to be imported
15+
from wrapt import ObjectProxy
16+
import_exc = None
17+
except ImportError as exc:
18+
ObjectProxy = object
19+
import_exc = exc
1320

1421
from .interface import Bus
1522
from .bus import BusABC
@@ -52,6 +59,9 @@ class ThreadSafeBus(ObjectProxy):
5259
_lock_recv = RLock()
5360

5461
def __init__(self, *args, **kwargs):
62+
if import_exc is not None:
63+
raise import_exc
64+
5565
super(ThreadSafeBus, self).__init__(Bus(*args, **kwargs))
5666

5767
# now, BusABC.send_periodic() does not need a lock anymore, but the

0 commit comments

Comments
 (0)