Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Is there a way to detect a pause in data reception? #127

Open
betov75 opened this issue Nov 21, 2020 · 1 comment
Open

Question: Is there a way to detect a pause in data reception? #127

betov75 opened this issue Nov 21, 2020 · 1 comment

Comments

@betov75
Copy link

betov75 commented Nov 21, 2020

Hi! I need to detect when data stops entering for at least X ms. For example, when data is entering, if, for example, 300 ms passed between two lines, a function is launched. Can this jeopardize the perofmrnance a lot?
Thank you very much for your answer(s)

@attwad
Copy link
Owner

attwad commented Nov 23, 2020

You could either:

  • keep track of the last time a handler was called (assuming you catch all incoming events) and update that time in each handler as well as check for the duration you want.
  • start a timer that you'd cancel/restart on each handler, there are many ways to do that depending on the way you run your program (sched-based, signal.alarm based, threading.Timer based etc, read through those and pick the one you want)

Neither option should really be costing much, just make sure you're not blocking (never call time.sleep).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants