#
# This file is part of Hooke.
#
-# Hooke is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either
-# version 3 of the License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
#
-# Hooke is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+# Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with Hooke. If not, see
feed(buffer, notempty, s, writelock, close)
multiprocessing.queues.Queue._feed = staticmethod(new_feed)
+import logging
+import logging.config
import multiprocessing
import optparse
import os.path
+import Queue
import unittest
+import StringIO
import sys
from . import engine as engine
default_settings=default_settings)
config.read()
self.config = config
+ self.load_log()
self.load_plugins()
self.load_drivers()
self.load_ui()
self.command = engine.CommandEngine()
-
self.playlists = playlist.NoteIndexList()
+ def load_log(self):
+ config_file = StringIO.StringIO()
+ self.config.write(config_file)
+ logging.config.fileConfig(StringIO.StringIO(config_file.getvalue()))
+ # Don't attach the logger because it contains an unpicklable
+ # thread.lock. Instead, grab it directly every time you need it.
+ #self.log = logging.getLogger('hooke')
+
def load_plugins(self):
self.plugins = plugin_mod.load_graph(
plugin_mod.PLUGIN_GRAPH, self.config, include_section='plugins')
return (ui_to_command, command_to_ui, command)
def _cleanup_run(self, ui_to_command, command_to_ui, command):
+ log = logging.getLogger('hooke')
+ log.debug('cleanup sending CloseEngine')
ui_to_command.put(ui.CloseEngine())
- hooke = command_to_ui.get()
- assert isinstance(hooke, Hooke)
+ hooke = None
+ while not isinstance(hooke, Hooke):
+ log.debug('cleanup waiting for Hooke instance from the engine.')
+ hooke = command_to_ui.get(block=True)
+ log.debug('cleanup got %s instance' % type(hooke))
command.join()
return hooke