chore(readme): Updated docs
[plugin.video.netflix.git] / service.py
1 import threading
2 import SocketServer
3 import xbmc
4 from resources.lib.common import log
5 from resources.lib.MSLHttpRequestHandler import MSLHttpRequestHandler
6
7 PORT = 8000
8 Handler = MSLHttpRequestHandler
9 SocketServer.TCPServer.allow_reuse_address = True
10 server = SocketServer.TCPServer(('127.0.0.1', PORT), Handler)
11 server.server_activate()
12 server.timeout = 1
13
14 if __name__ == '__main__':
15     monitor = xbmc.Monitor()
16     thread = threading.Thread(target=server.serve_forever)
17     thread.daemon = True
18     thread.start()
19
20     while not monitor.abortRequested():
21         if monitor.waitForAbort(5):
22             server.shutdown()
23             break
24
25     server.server_close()
26     server.socket.close()
27     server.shutdown()
28     log("Stopped MSL Service")