'Disconnects from printer and pauses the print'

@locked
def disconnect(self):

    if self.printer:
        if self.read_thread:
            self.stop_read_thread = True
            if (threading.current_thread() != self.read_thread):
                self.read_thread.join()
            self.read_thread = None
        if self.print_thread:
            self.printing = False
            self.print_thread.join()
        self._stop_sender()
        try:
            self.printer.close()
        except socket.error:
            pass
        except OSError:
            pass
    for handler in self.event_handler:
        try:
            handler.on_disconnect()
        except:
            logging.error(traceback.format_exc())
    self.printer = None
    self.online = False
    self.printing = False
