Skip to content

Race in client between write and read #458

Description

@alexddobkin

versioin : 4.13.3

symptomps

packet queue is empty, aborting
Exception in thread Thread-2 (_read_loop_websocket):
Traceback (most recent call last):
  File "/python/Python-3.11.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/python/Python-3.11.11/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/python/Python-3.11.11/lib/python3.11/site-packages/engineio/client.py", line 562, in _read_loop_websocket
    self.write_loop_task.join()
    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'join'
        # start background tasks associated with this client
        self.write_loop_task = self.start_background_task(self._write_loop)    <======== starts a thread
        self.read_loop_task = self.start_background_task(self._read_loop_polling)  <======== starts a thread

   def _write_loop(self):
      ....
      self.write_loop_task = None
   
   def _read_loop_polling(self):
      ...
      if self.write_loop_task:  # pragma: no branch
          self.logger.info('Waiting for write loop task to end')
          self.write_loop_task.join()   <== self.write_loop_task could be None !!

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions