medved/lib/data/Source.py

21 lines
606 B
Python
Raw Normal View History

2018-04-02 22:41:10 +00:00
from lib import Service
class Source(Service):
2018-04-02 23:47:50 +00:00
"""Base class for datasources"""
2018-04-02 22:41:10 +00:00
def __init__(self, thread, id, root):
super().__init__(thread, id, root)
self._logger.add_field('service', 'Feed')
self._logger.add_field('vname', self.__class__.__name__)
self._item = {
2018-04-02 22:41:10 +00:00
'source': self._id,
'steps': {},
'data': {}
2018-04-02 22:41:10 +00:00
}
def next(self, count=10, block=False):
if self._running or not self._data.count() == 0:
return self._data.get(count=count, block=block)
elif self._data.count() == 0:
raise Exception("Storage is empty, generator is stopped")