Skip to content

Updating word lists with talon.cron can cause RuntimeError: dictionary changed size during iteration #120

Description

@jgarvin

I haven't tried to make a minimal test case but was asked to file, so here's what I know :)

Example trace:

   25:                lib/python3.7/threading.py:890| 
   24:                lib/python3.7/threading.py:926| 
   23:                lib/python3.7/threading.py:870| 
   22:                             talon/cron.py:112| 
   21: ---------------------------------------------# cron thread
   20:                             talon/cron.py:77 | 
   19:                   talon/scripting/rctx.py:200| 
   18: ---------------------------------------------# 'cron' user.knausj_talon.mandimus.emacs.snippet:call()
   17:                             talon/cron.py:134| 
   16: user/knausj_talon/mandimus/emacs/query.py:169| self._commit(processed)
   15: user/knausj_talon/mandimus/emacs/query.py:187| self.ctx.lists[f"user.{self.name}_list..
   14:                talon/scripting/context.py:67 | 
   13:                talon/scripting/context.py:223| 
   12:               talon/scripting/registry.py:273| 
   11:               talon/scripting/registry.py:469| 
   10:               talon/scripting/dispatch.py:98 | 
    9:               talon/scripting/dispatch.py:133| 
    8:               talon/scripting/dispatch.py:126| 
    7:                   talon/scripting/rctx.py:202| 
    6: ---------------------------------------------# 'update_lists' main:update_lists()
    5: ---------------------------------------------# stack splice
    4:                   talon/scripting/rctx.py:200| 
    3:          talon/scripting/speech_system.py:215| 
    2:          talon/scripting/speech_system.py:85 | 
    1:                      talon/engines/w2l.py:616| 

Deep in my cron callback I was doing:

self.ctx.lists[f"user.{self.name}_list"] = data.keys()

Which curiously seems mitigated by (haven't had it happen since):

self.ctx.lists[f"user.{self.name}_list"] = list(data.keys())

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions