Skip to content

Periodic sync example? #376

Discussion options

You must be logged in to vote

oh yeah....the docs don't include the simplest way to use sync data. I should add a better example.

Give this a go:

import time
from collections.abc import Mapping

def update(d, u):
    for k, v in u.items():
        d[k] = update(d.get(k, {}), v) if isinstance(v, Mapping) else v
    return d

maindata = client.sync_maindata()

while True:
    print(f"Upload: {maindata.server_state.up_info_speed}, Download: {maindata.server_state.dl_info_speed}")
    maindata = update(maindata, client.sync.maindata.delta())
    time.sleep(1)

client.sync.maindata.delta() can keep track of the rid for you between subsequent calls.

Although, there isn't anything to keep a full up-to-date maindata....that pr…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by thytrherfvsefasfd443sf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants