Skip to content

Commit

Permalink
Minor code formatting changes in server module
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestaylr committed Jul 13, 2015
1 parent 1f295f1 commit fdf7b10
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/modules/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ def on_close(self):


class IndexHandler(tornado.web.RequestHandler):

@tornado.web.asynchronous
def get(self):
self.render('../web/index.html')


class Application(tornado.web.Application):

def __init__(self):
handlers = [(r'/ws', WSHandler), (r'/', IndexHandler)]
settings = {'debug': True,
Expand All @@ -62,15 +59,9 @@ def __init__(self):
application = Application()

class ServerThread(StoppableThread):

""" Creates thread which runs the web socket server
"""

def send_data(self, message):
for ws in wss:

# do not log any data here, doing so would create an infinite loop

# Do not log any data here, doing so would create an infinite loop
try:
ws.write_message(message)
break
Expand All @@ -84,10 +75,10 @@ def close_sockets(self):

def run(self):
global target_locations, boundary_locations

logger.info('Starting server.')
# defining the locations array

# Defining the locations array
target_locations = self._kwargs['target_locations']
boundary_locations = self._kwargs['boundary_locations']

Expand All @@ -112,12 +103,8 @@ def shutdown():
logger.info('The web server successfully bound to port %d'
% self._kwargs['port'])

# starts the main IO loop
# Starts the main IO loop
main_loop.start()

except OSError:
logger.critical('The web server failed to bind to the port!')




0 comments on commit fdf7b10

Please sign in to comment.