Skip to content

Unsolicited replies can cause threading error #285

@DominicOram

Description

@DominicOram

If unsolicited_reply is called periodically in a thread e.g.:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions