Beispiel #1
0
def _tcp_query_handler_thread():
  global query_times

  while True:
    try:
      query = pending_tcp_queries.get(block=True)
      response = _handle_request(query['request'])

      session.session_sendmessage(query['socket'], response)

      query['socket'].close()
      query_times.append(time.time() - query['start_time'])
    except Exception, e:
      _log_with_timestamp("Exception while handling request (from %s): " % str(query['socket'].getpeername()) +
      str(query) + "\n" +  traceback.format_exc() + '\n', 'error')
Beispiel #2
0
def _tcp_query_handler_thread():
    global query_times

    while True:
        try:
            query = pending_tcp_queries.get(block=True)
            response = _handle_request(query['request'])

            session.session_sendmessage(query['socket'], response)

            query['socket'].close()
            query_times.append(time.time() - query['start_time'])
        except Exception, e:
            _log_with_timestamp(
                "Exception while handling request (from %s): " %
                str(query['socket'].getpeername()) + str(query) + "\n" +
                traceback.format_exc() + '\n', 'error')
def _tcp_query_handler_thread():
    """
  <Purpose>
    Handles all TCP requests that were previously received in
    pending_tcp_queries.  This is NOT threadsafe, and should only be
    run from one thread only.

    This is meant to be a persistent thread that continuously runs in
    the background.  Remember to set daemon mode, otherwise this thread
    can cause the process to run indefinitely even when the main thread
    is interrupted.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Effects>
    Will log to the error file when receiving exceptions.

  <Returns>
    None
  """
    global query_times

    while True:
        try:
            query = pending_tcp_queries.get(block=True)
            response = _handle_request(query["request"])

            session.session_sendmessage(query["socket"], response)

            query["socket"].close()
            query_times.append(time.time() - query["start_time"])
        except Exception, e:
            _log_with_timestamp(
                "Exception while handling request (from %s): " % str(query["socket"].getpeername())
                + str(query)
                + "\n"
                + traceback.format_exc()
                + "\n",
                "error",
            )
Beispiel #4
0
def _tcp_query_handler_thread():
    """
  <Purpose>
    Handles all TCP requests that were previously received in
    pending_tcp_queries.  This is NOT threadsafe, and should only be
    run from one thread only.

    This is meant to be a persistent thread that continuously runs in
    the background.  Remember to set daemon mode, otherwise this thread
    can cause the process to run indefinitely even when the main thread
    is interrupted.

  <Arguments>
    None

  <Exceptions>
    None

  <Side Effects>
    Will log to the error file when receiving exceptions.

  <Returns>
    None
  """
    global query_times

    while True:
        try:
            query = pending_tcp_queries.get(block=True)
            response = _handle_request(query['request'])

            session.session_sendmessage(query['socket'], response)

            query['socket'].close()
            query_times.append(time.time() - query['start_time'])
        except Exception, e:
            _log_with_timestamp(
                "Exception while handling request (from %s): " %
                str(query['socket'].getpeername()) + str(query) + "\n" +
                traceback.format_exc() + '\n', 'error')