Annotation of zerver/lib/handlers.py.

This commit is contained in:
Ashish 2016-04-04 14:18:52 +05:30 committed by Tim Abbott
parent 86a8d3d0f5
commit 9cfa7d5765
1 changed files with 5 additions and 0 deletions

View File

@ -6,9 +6,11 @@ current_handler_id = 0
handlers = {} # type: Dict[int, Any] # TODO: Should be AsyncDjangoHandler but we don't important runtornado.py. handlers = {} # type: Dict[int, Any] # TODO: Should be AsyncDjangoHandler but we don't important runtornado.py.
def get_handler_by_id(handler_id): def get_handler_by_id(handler_id):
# type: (int) -> Any # TODO: should be AsyncDjangoHandler, see above
return handlers[handler_id] return handlers[handler_id]
def allocate_handler_id(handler): def allocate_handler_id(handler):
# type: (Any) -> int # TODO: should be AsyncDjangoHandler, see above
global current_handler_id global current_handler_id
handlers[current_handler_id] = handler handlers[current_handler_id] = handler
handler.handler_id = current_handler_id handler.handler_id = current_handler_id
@ -16,12 +18,15 @@ def allocate_handler_id(handler):
return handler.handler_id return handler.handler_id
def clear_handler_by_id(handler_id): def clear_handler_by_id(handler_id):
# type: (int) -> None
del handlers[handler_id] del handlers[handler_id]
def handler_stats_string(): def handler_stats_string():
# type: () -> str
return "%s handlers, latest ID %s" % (len(handlers), current_handler_id) return "%s handlers, latest ID %s" % (len(handlers), current_handler_id)
def finish_handler(handler_id, event_queue_id, contents, apply_markdown): def finish_handler(handler_id, event_queue_id, contents, apply_markdown):
# type: (int, int, List[Dict[str, Any]], bool) -> None
err_msg = "Got error finishing handler for queue %s" % (event_queue_id,) err_msg = "Got error finishing handler for queue %s" % (event_queue_id,)
try: try:
# We call async_request_restart here in case we are # We call async_request_restart here in case we are