Import ui before threadutil to resolve circular dependency

The `threadutil` module depends on the `ui` module, which cycle depends
on `threadutil` through the `Curses` module.

The `ui` module had been loaded before the `threadutil` module, breaking
the above circular dependency, but this was changed in a recent code
refactoring, preventing the `Curses` module from being loaded with the
following exception:

  File "./offlineimap.py", line 23, in <module>
    from offlineimap import OfflineImap
  File "offlineimap/offlineimap/__init__.py", line 20, in <module>
    from offlineimap.init import OfflineImap
  File "offlineimap/offlineimap/init.py", line 30, in <module>
    from offlineimap import globals, threadutil, accounts, folder, mbnames
  File "offlineimap/offlineimap/threadutil.py", line 25, in <module>
    from offlineimap.ui import getglobalui
  File "offlineimap/offlineimap/ui/__init__.py", line 28, in <module>
    from offlineimap.ui import Curses
  File "offlineimap/offlineimap/ui/Curses.py", line 27, in <module>
    from offlineimap.threadutil import ExitNotifyThread
ImportError: cannot import name ExitNotifyThread

Fix the above error by ensuring that the `ui` module gets loaded before
the `threadutil` module. Please note that the above fix is temporary,
and we should refactor the modules to not have circular dependencies.

Bug-Debian: https://bugs.debian.org/839862
Reported-by: Neil McGovern <neilm@debian.org>
Signed-off-by: Ilias Tsitsimpis <i.tsitsimpis@gmail.com>
This commit is contained in:
Ilias Tsitsimpis 2016-10-06 13:30:48 +03:00
parent d98a1651ca
commit 3addbb3a54
1 changed files with 4 additions and 1 deletions

View File

@ -27,8 +27,11 @@ from optparse import OptionParser
import offlineimap
import offlineimap.virtual_imaplib2 as imaplib
from offlineimap import globals, threadutil, accounts, folder, mbnames
# Ensure that `ui` gets loaded before `threadutil` in order to
# break the circular dependency between `threadutil` and `Curses`.
from offlineimap.ui import UI_LIST, setglobalui, getglobalui
from offlineimap import globals, threadutil, accounts, folder, mbnames
from offlineimap.CustomConfig import CustomConfigParser
from offlineimap.utils import stacktrace
from offlineimap.repository import Repository