MCPcopy Index your code
hub / github.com/USArmyResearchLab/Dshell / _handle_connection

Method _handle_connection

dshell/core.py:655–686  ·  view source on GitHub ↗

Handles produced connections. :returns: True if connection was handled successfully.

(self, conn: "Connection", full=False)

Source from the content-addressed store, hash-verified

653 pass
654
655 def _handle_connection(self, conn: "Connection", full=False) -> bool:
656 """
657 Handles produced connections.
658
659 :returns: True if connection was handled successfully.
660 """
661 try:
662 connection_handler_out = self.connection_handler(conn)
663 except Exception as e:
664 print_handler_exception(e, self, 'connection_handler')
665 return False
666 conn.handled = True
667
668 # TODO: Perhaps connection_handler() just returns a True or False indicating success?
669 if connection_handler_out and not isinstance(connection_handler_out, Connection):
670 logger.warning(
671 "The output from {} connection_handler must be of type dshell.Connection! Chaining plugins from here may not be possible.".format(
672 self.name))
673 connection_handler_out = None
674
675 if not connection_handler_out:
676 return False
677
678 with self.handled_conn_count.get_lock():
679 self.handled_conn_count.value += 1
680
681 if full:
682 try:
683 self.connection_close_handler(conn)
684 except Exception as e:
685 print_handler_exception(e, self, 'connection_close_handler')
686 return True
687
688 def _timeout_connections(self, timestamp: datetime.datetime):
689 """

Callers 1

produce_connectionsMethod · 0.95

Calls 3

connection_handlerMethod · 0.95
print_handler_exceptionFunction · 0.85

Tested by

no test coverage detected