Used hooke.hooke.TestHooke to isolate Queue issue to
HookeConfigParser:
======================================================================
ERROR: Ensure :class:`HookeConfigParser` is Queue-safe
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/hooke/hooke/config.py", line 270, in test_queue_safe
b = q.get(a)
File "/usr/lib/python2.6/multiprocessing/queues.py", line 91, in get
res = self._recv()
File "/tmp/hooke/hooke/compat/odict.py", line 214, in __setitem__
self._keys.append(key)
AttributeError: 'odict' object has no attribute '_keys'
import ConfigParser as configparser
import os.path
import textwrap
import ConfigParser as configparser
import os.path
import textwrap
from .compat.odict import odict as OrderedDict
from .compat.odict import odict as OrderedDict
DEFAULT_PATHS = [
'/usr/share/hooke/hooke.cfg',
'/etc/hooke/hooke.cfg',
DEFAULT_PATHS = [
'/usr/share/hooke/hooke.cfg',
'/etc/hooke/hooke.cfg',
self.help = help
self.wrap = wrap
self.help = help
self.wrap = wrap
+ def __eq__(self, other):
+ for attr in ['__class__', 'section', 'option', 'value', 'help']:
+ value = getattr(self, attr)
+ o_value = getattr(other, attr)
+ if o_value != value:
+ return False
+ return True
+
def is_section(self):
return self.option == None
def is_section(self):
return self.option == None
if local_fp:
fp = open(os.path.expanduser(self._config_paths[-1]), 'w')
if self._defaults:
if local_fp:
fp = open(os.path.expanduser(self._config_paths[-1]), 'w')
if self._defaults:
self._write_setting(fp, configparser.DEFAULTSECT,
help="Miscellaneous options")
for (key, value) in self._defaults.items():
self._write_setting(fp, configparser.DEFAULTSECT,
help="Miscellaneous options")
for (key, value) in self._defaults.items():
fp.write("\n")
if local_fp:
fp.close()
fp.write("\n")
if local_fp:
fp.close()
+
+class TestHookeConfigParser (unittest.TestCase):
+ def test_queue_safe(self):
+ """Ensure :class:`HookeConfigParser` is Queue-safe.
+ """
+ from multiprocessing import Queue
+ q = Queue()
+ a = HookeConfigParser(
+ paths=DEFAULT_PATHS, default_settings=DEFAULT_SETTINGS)
+ q.put(a)
+ b = q.get(a)
+ for attr in ['_dict', '_defaults', '_sections', '_config_paths',
+ '_default_settings']:
+ a_value = getattr(a, attr)
+ b_value = getattr(b, attr)
+ self.failUnless(
+ a_value == b_value,
+ 'HookeConfigParser.%s did not survive Queue: %s != %s'
+ % (attr, a_value, b_value))