-
Notifications
You must be signed in to change notification settings - Fork 4
/
tracker.py
27 lines (23 loc) · 825 Bytes
/
tracker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sys
import threading
from trackermodule.trackerconfighandler import TrackerConfigHandler
from trackermodule.threadedtrackerserver import ThreadedTrackerServer
if __name__ == "__main__":
server = None
try:
tracker_config = TrackerConfigHandler()
tracker_host = ''
tracker_port = tracker_config.tracker_port
tracker_server_address = (tracker_host, tracker_port)
server = ThreadedTrackerServer(tracker_server_address)
server.listen()
except Exception as err:
print("Oops! Error: {}.".format(err))
finally:
main_thread = threading.current_thread()
for t in threading.enumerate():
if t is main_thread:
continue
t.close_connection()
if server:
server.stop_server()