1. TortoiseHg
  2. TortoiseHg
  3. thg
  4. Issues
Issue #1894 resolved

Error when closing Thg: KeyError in module 'threading'

Anonymous created an issue

When closing Thg workbench, a popup: "Errors occured. See the logfile...thgw.exe.log". Version 2.4 on XP SP3

File thgw.exe.log content:

--- begin---

Exception KeyError: KeyError(3992,) in <module 'threading' from 'C:\Program Files\TortoiseHg\library.zip\threading.pyo'> ignored

Exception KeyError: KeyError(2884,) in <module 'threading' from 'C:\Program Files\TortoiseHg\library.zip\threading.pyo'> ignored

--- end----

Comments (8)

  1. Yuya Nishihara

    Thanks. It can be reproduced by:

    • thg status
    • against repository containing empty svn subrepos
    • on Windows
    • by using frozen exe (installed by msi)

    I couldn't see this error by using source install.

    3992 of KeyError(3992,) seems the id of the main thread.

  2. Yuya Nishihara

    Found out this issue is side effect of Mercurial's demandimport.

    threading module must be loaded by main thread because it instantiates fake MainThread object. Otherwise, the thread id of MainThread object gets wrong.


    If there are svn subrepos, svnsubrepo._svncommand will be invoked in sub thread, which loads subprocess module. On Windows, subprocess module uses threading.Thread, which means threading module is also loaded by sub thread. Thus, KeyError occurs.

  3. Yuya Nishihara

    thg: make sure to load threading module by main thread (fixes #1894)

    threading must be loaded by main thread, but in some cases, it is loaded inside CmdThread, which leads KeyError at exit.

    Instead of excluding every module which depends on threading from demandimport, I chose to load threading before demandimport.

    → <<cset 2339e63eda30>>

  4. Log in to comment