TargetProcess / signalr-client-py

python client proxy for signalr
Other
63 stars 58 forks source link

ValueError: generator already executing #42

Closed troyhoffman closed 6 years ago

troyhoffman commented 6 years ago

I'm getting this exception randomly, but consistently in my code. Trace is below. I'm trying to narrow it down to some code I can post, but when I do that, the problem goes away. I can try again Monday. The exception is in _sse_transport.ServerSentEventsTransport.start._receive(). From what I could gather with Google, this particular exception is usually caused by code that isn't thread safe and two threads try to use the same generator at the same time.

My code also uses threading and it frequently calls the invoke method to force the application I'm testing to send updated data, so it might be related to that. I was able to fix it by using a threading.Lock context manager when executing notification = next(self.__response). It seems to work, but I'm not sure what side effects this could cause and want to look into it some more before committing and creating a pull request.

The traceback follows (directories obfuscated):

Exception in thread Thread-3: Traceback (most recent call last): File "<pythonpath>\lib\threading.py", line 916, in _bootstrap_inner self.run() File "<pythonpath>\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "<venv path>\lib\site-packages\signalr\_connection.py", line 55, in wrapped_listener listener() File "<venv path>\lib\site-packages\signalr\transports\_sse_transport.py", line 23, in _receive notification = next(self.__response) File "<venv path>\lib\site-packages\sseclient.py", line 65, in __next__ next_chunk = next(self.resp_iterator) ValueError: generator already executing Exception in thread Thread-1: Traceback (most recent call last): File "<pythonpath>\lib\threading.py", line 916, in _bootstrap_inner self.run() File "<pythonpath>\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "<venv path>\lib\site-packages\signalr\_connection.py", line 55, in wrapped_listener listener() File "<venv path>\lib\site-packages\signalr\transports\_sse_transport.py", line 23, in _receive notification = next(self.__response) File "<venv path>\lib\site-packages\sseclient.py", line 65, in __next__ next_chunk = next(self.resp_iterator) ValueError: generator already executing

troyhoffman commented 6 years ago

Sorry. I was in the wrong fork when I posted this. Please ignore.