don't expose scheduler
This commit is contained in:
parent
b040ede864
commit
3ffc72f065
1 changed files with 18 additions and 8 deletions
|
@ -11,6 +11,8 @@ _logger = logging.getLogger(__name__)
|
|||
|
||||
class DavFile:
|
||||
__instances = None
|
||||
__scheduler = None
|
||||
__job = None
|
||||
|
||||
def __init__(self, client: Client, path: Any) -> None:
|
||||
self.__resource: Resource = client.resource(path)
|
||||
|
@ -31,21 +33,29 @@ class DavFile:
|
|||
self.__resource.write_to(self.__buffer)
|
||||
|
||||
@classmethod
|
||||
def refresh(cls, refresh_interval: int = 5) -> AsyncIOScheduler:
|
||||
scheduler = AsyncIOScheduler()
|
||||
def refresh(cls, refresh_interval: int = 60):
|
||||
if cls.__job is not None:
|
||||
cls.__scheduler.reschedule_job(
|
||||
job_id=cls.__name__,
|
||||
trigger="interval",
|
||||
seconds=refresh_interval,
|
||||
)
|
||||
return
|
||||
|
||||
def tick() -> None:
|
||||
for davfile in DavFile.__instances:
|
||||
davfile.update()
|
||||
|
||||
scheduler.add_job(tick)
|
||||
scheduler.add_job(
|
||||
tick, "interval",
|
||||
cls.__scheduler = AsyncIOScheduler()
|
||||
cls.__scheduler.start()
|
||||
|
||||
cls.__scheduler.add_job(tick)
|
||||
cls.__job = cls.__scheduler.add_job(
|
||||
tick,
|
||||
id=cls.__name__,
|
||||
trigger="interval",
|
||||
seconds=refresh_interval,
|
||||
)
|
||||
scheduler.start()
|
||||
|
||||
return scheduler
|
||||
|
||||
@property
|
||||
def bytes(self) -> bytes:
|
||||
|
|
Loading…
Reference in a new issue