Closed danfoster closed 1 year ago
The intention is to avoid socket creation by PySolarmanV5. The code here was added with #33 and indeed must be wrapped in something like this:
elif isinstance(self.sock, socket.socket):
self._poll = select.poll()
self._sock_fd = self.sock.fileno()
self._auto_reconnect = False if kwargs.get('socket') else kwargs.get('auto_reconnect', False)
self._data_queue = Queue(maxsize=1)
self._data_wanted = Event()
self._reader_exit = Event()
self._reader_thr = Thread(target=self._data_receiver, daemon=True)
self._reader_thr.start()
otherwise two simultaneous connections will be opened to the data logger.
Ah nice! Yes, that logic does sound familiar. Thanks for correcting me. Looking like you've already got an WIP branch with the correct approach for the fix, so I'll close this.
Yes, I had to write data logger simulator in order to catch other issues as well. Looks good for now. Don't know what @jmccrohan will say about these changes though.
@danfoster @githubDante Thanks for this. I was working on tidying up for release. Send on your branch as a PR and I'll merge.
I'm not sure what the original intention of adding the
socket
kwarg as an empty string here, but as you can see if you create thePySolarmanV5Async
, it always fails with the following:Therefore this PR proposes removing this line.