Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit d9110cc

Browse files
committed
add methods to stop archiving and clear caches
1 parent fa36522 commit d9110cc

2 files changed

Lines changed: 43 additions & 9 deletions

File tree

PyTangoArchiving/hdbpp/config.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -753,17 +753,24 @@ def start_archiving(self,attribute,archiver,period=0,
753753
%(attribute,traceback.format_exc().replace('\n','')))
754754
return False
755755

756-
def stop_archiving(self, attribute):
756+
def stop_archiving(self, attribute, clear=True):
757757
"""
758758
This method will remove the attribute from an existing archiver
759759
"""
760-
attribute = self.is_attribute_archived(attribute)
761-
if attribute:
762-
self.warning('Stopping %s' % attribute)
763-
self.get_manager().AttributeStop(attribute)
764-
else:
765-
self.wanring('%s is not archived!' % attribute)
766-
return attribute
760+
try:
761+
attribute = self.is_attribute_archived(attribute)
762+
if attribute:
763+
arch = self.get_attribute_archiver(attribute)
764+
self.warning('Removing %s from %s' % (attribute,arch))
765+
self.get_manager().AttributeRemove(attribute)
766+
if clear:
767+
self.clear_caches()
768+
else:
769+
self.warning('%s is not archived!' % attribute)
770+
return attribute
771+
except:
772+
self.warning('stop_archiving(%s) failed!' %
773+
(attribute, traceback.format_exc()))
767774

768775
def restart_attribute(self,attr, d=''):
769776
try:
@@ -803,7 +810,12 @@ def restart_attributes(self,attributes=None,timewait=0.5):
803810

804811
print('%d attributes restarted' % len(attributes))
805812

806-
813+
def clear_caches(self):
814+
self.get_attribute_archiver.cache.clear()
815+
self.get_archiver_attributes.cache.clear()
816+
self.get_attribute_subscriber.cache.clear()
817+
self.get_archivers_attributes.cache.clear()
818+
self.dedicated = {}
807819

808820

809821

PyTangoArchiving/hdbpp/periodic.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,25 @@ def add_periodic_attributes(self,attributes,periods,wait=3.):
180180

181181
return done
182182

183+
def stop_periodic_archiving(self, attribute):
184+
try:
185+
attribute = parse_tango_model(attribute, fqdn=True).fullname.lower()
186+
arch = self.get_periodic_attribute_archiver(attribute)
187+
if not arch:
188+
self.warning('%s is not archived!' % attribute)
189+
else:
190+
self.info('Removing %s from %s' % (attribute, arch))
191+
dp = fn.get_device(archiver)
192+
v = dp.AttributeRemove([attribute, str(int(float(period)))])
193+
dp.UpdateAttributeList()
194+
fn.wait(wait)
195+
return v
196+
except:
197+
self.warning('stop_periodic_archiving(%s) failed!' %
198+
(attribute, traceback.format_exc()))
199+
200+
def clear_periodic_caches(self):
201+
self.get_periodic_archiver_attributes.cache.clear()
202+
self.get_periodic_archivers_attributes.cache.clear()
203+
self.get_periodic_attribute_archiver.cache.clear()
204+
self.get_periodic_attribute_period.cache.clear()

0 commit comments

Comments
 (0)