ISISComputingGroup / ISISComputingGroup/lewis

Unsolicited replies can cause threading error

Open
#285 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
24
Forks
19
PR merge metrics
No merged PRs in 30d

Description

If `unsolicited_reply` is called periodically in a thread e.g.:
```python
def get_data_unsolicited(self):
timer = threading.Timer(0.1, self.get_data_unsolicited)
timer.start
self.handler.unsolicited_reply(b"TEST")
```
there will be an occasional stack trace of:
```
Exception in thread Thread-911:
Traceback (most recent call last):
File "c:\instrument\apps\python\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "c:\instrument\apps\python\lib\threading.py", line 1072, in run
self.function(*self.args, **self.kwargs)
File "C:\Instrument\Apps\epics\support\DeviceEmulator\master\lewis_emulators\mecfrf\interfaces\stream_interface.py", line 48, in get_data_unsolicited
handler.unsolicited_reply(b"TEST")
File "c:\instrument\apps\python\lib\site-packages\lewis\adapters\stream.py", line 116, in unsolicited_reply
self.push(b(reply + self._target.out_terminator))
File "c:\instrument\apps\python\lib\asynchat.py", line 193, in push
self.initiate_send()
File "c:\instrument\apps\python\lib\asynchat.py", line 251, in initiate_send
del self.producer_fifo[0]
IndexError: deque index out of range
```
This stack trace does not appear to affect whether the message is actually sent or not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.