File: keepalive.py

package info (click to toggle)
jellyfin-apiclient-python 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 276 kB
  • sloc: python: 1,690; sh: 5; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import threading

class KeepAlive(threading.Thread):
    def __init__(self, timeout, ws):
        self.halt           = threading.Event()
        self.timeout        = timeout
        self.ws             = ws

        threading.Thread.__init__(self)
    
    def stop(self):
        self.halt.set()
        self.join()

    def run(self):
        while not self.halt.is_set():
            if self.halt.wait(self.timeout/2):
                break
            else:
                self.ws.send("KeepAlive")