@@ -215,7 +215,6 @@ class LEDCollection(CompositeOutputDevice):
215
215
:class:`LEDBoard` and :class:`LEDBarGraph`.
216
216
"""
217
217
def __init__ (self , * args , ** kwargs ):
218
- self ._blink_thread = None
219
218
pwm = kwargs .pop ('pwm' , False )
220
219
active_high = kwargs .pop ('active_high' , True )
221
220
initial_value = kwargs .pop ('initial_value' , False )
@@ -313,12 +312,16 @@ class LEDBoard(LEDCollection):
313
312
create trees of LEDs.
314
313
"""
315
314
def __init__ (self , * args , ** kwargs ):
315
+ self ._blink_thread = None
316
316
self ._blink_leds = []
317
317
self ._blink_lock = Lock ()
318
318
super (LEDBoard , self ).__init__ (* args , ** kwargs )
319
319
320
320
def close (self ):
321
- self ._stop_blink ()
321
+ try :
322
+ self ._stop_blink ()
323
+ except AttributeError :
324
+ pass
322
325
super (LEDBoard , self ).close ()
323
326
324
327
def on (self , * args ):
@@ -1373,10 +1376,10 @@ def __init__(self, pin_factory=None):
1373
1376
)
1374
1377
1375
1378
def close (self ):
1376
- if self . _lock :
1379
+ if getattr ( self , ' _lock' , None ) :
1377
1380
with self ._lock :
1378
1381
super (_EnergenieMaster , self ).close ()
1379
- self ._lock = None
1382
+ self ._lock = None
1380
1383
1381
1384
@classmethod
1382
1385
def _shared_key (cls , pin_factory ):
@@ -1442,10 +1445,9 @@ def __init__(self, socket=None, initial_value=False, pin_factory=None):
1442
1445
self .off ()
1443
1446
1444
1447
def close (self ):
1445
- if self ._master :
1446
- m = self ._master
1447
- self ._master = None
1448
- m .close ()
1448
+ if getattr (self , '_master' , None ):
1449
+ self ._master .close ()
1450
+ self ._master = None
1449
1451
1450
1452
@property
1451
1453
def closed (self ):
0 commit comments