Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError with _rcv_buffer #45

Open
pmoosman opened this issue Mar 22, 2023 · 0 comments
Open

KeyError with _rcv_buffer #45

pmoosman opened this issue Mar 22, 2023 · 0 comments

Comments

@pmoosman
Copy link

We encountered the following KeyError while running latest version, 2.0.12:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
File "/usr/local/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.10/site-packages/j1939/electronic_control_unit.py", line 282, in _async_job_thread
    next_wakeup = self.j1939_dll.async_job_thread(now)
File "/usr/local/lib/python3.10/site-packages/j1939/j1939_21.py", line 162, in async_job_thread
    buf = self._rcv_buffer[bufid]
KeyError: 33023

Here is the code snippet:

      # check receive buffers for timeout
       # using "list(x)" to prevent "RuntimeError: dictionary changed size during iteration"
       for bufid in list(self._rcv_buffer):
           buf = self._rcv_buffer[bufid]

My guess is that try catch block should wrap "buf = self._rcv_buffer[bufid]" to catch the key error.

I assume a different thread has deleted that particular bufid inbetween the "for in" statement and the dictionary lookup.

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant