File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,28 +37,23 @@ def import_memcached():
3737 from .memcached import MemcachedBackend
3838
3939 return MemcachedBackend
40- except ModuleNotFoundError :
41- warnings .warn (
42- "MemcachedBackend is not available. Run `pip install dramatiq[memcached]` "
43- "to add support for that backend." ,
44- category = ImportWarning ,
45- stacklevel = 2 ,
40+ except ModuleNotFoundError as e :
41+ message = (
42+ "MemcachedBackend is not available. Run `pip install dramatiq[memcached]` to add support for that backend."
4643 )
47- raise
44+ warnings .warn (message , category = ImportWarning , stacklevel = 3 )
45+ raise AttributeError (message ) from e
4846
4947
5048def import_redis ():
5149 try :
5250 from .redis import RedisBackend
5351
5452 return RedisBackend
55- except ModuleNotFoundError :
56- warnings .warn (
57- "RedisBackend is not available. Run `pip install dramatiq[redis]` to add support for that backend." ,
58- category = ImportWarning ,
59- stacklevel = 2 ,
60- )
61- raise
53+ except ModuleNotFoundError as e :
54+ message = "RedisBackend is not available. Run `pip install dramatiq[redis]` to add support for that backend."
55+ warnings .warn (message , category = ImportWarning , stacklevel = 3 )
56+ raise AttributeError (message ) from e
6257
6358
6459_module_importers = {
Original file line number Diff line number Diff line change @@ -37,28 +37,23 @@ def import_memcached():
3737 from .memcached import MemcachedBackend
3838
3939 return MemcachedBackend
40- except ModuleNotFoundError :
41- warnings .warn (
42- "MemcachedBackend is not available. Run `pip install dramatiq[memcached]` "
43- "to add support for that backend." ,
44- category = ImportWarning ,
45- stacklevel = 2 ,
40+ except ModuleNotFoundError as e :
41+ message = (
42+ "MemcachedBackend is not available. Run `pip install dramatiq[memcached]` to add support for that backend."
4643 )
47- raise
44+ warnings .warn (message , category = ImportWarning , stacklevel = 3 )
45+ raise AttributeError (message ) from e
4846
4947
5048def import_redis ():
5149 try :
5250 from .redis import RedisBackend
5351
5452 return RedisBackend
55- except ModuleNotFoundError :
56- warnings .warn (
57- "RedisBackend is not available. Run `pip install dramatiq[redis]` to add support for that backend." ,
58- category = ImportWarning ,
59- stacklevel = 2 ,
60- )
61- raise
53+ except ModuleNotFoundError as e :
54+ message = "RedisBackend is not available. Run `pip install dramatiq[redis]` to add support for that backend."
55+ warnings .warn (message , category = ImportWarning , stacklevel = 3 )
56+ raise AttributeError (message ) from e
6257
6358
6459_module_importers = {
You can’t perform that action at this time.
0 commit comments