Handles produced connections. :returns: True if connection was handled successfully.
(self, conn: "Connection", full=False)
| 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 | """ |
no test coverage detected