async def write(self, data):
        """
        This is an asyncio adapted version of pyserial write. It provides a
        non-blocking  write and returns the number of bytes written upon
        completion

        :param data: Data to be written
        :return: Number of bytes written
        """
        # the secret sauce - it is in your future
        future = asyncio.Future()
        result = None
        try:
            result = self.my_serial.write(bytes([ord(data)]))
        except serial.SerialException:
            # self.my_serial.close()
            # noinspection PyBroadException
            try:
                await self.close()
                future.cancel()
                if self.log_output:
                    logging.exception('Write exception')
                else:
                    print('Write exception')

                loop = asyncio.get_event_loop()
                for t in asyncio.Task.all_tasks(loop):
                    t.cancel()
                loop.run_until_complete(asyncio.sleep(.1))
                loop.stop()
                loop.close()
                self.my_serial.close()
                sys.exit(0)
            except:  # swallow any additional exceptions during shutdown
                pass

        if result:
            future.set_result(result)
            while True:
                if not future.done():
                    # spin our asyncio wheels until future completes
                    await asyncio.sleep(self.sleep_tune)

                else:
                    return future.result()
This is an asyncio adapted version of pyserial write. It provides a
        non-blocking  write and returns the number of bytes written upon
        completion

        :param data: Data to be written
        :return: Number of bytes written