From 155fa982b895b70572857ab25a324809470d74b3 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 21 Jun 2012 17:15:45 -0700 Subject: 1. Only register and increment the handler count after we have ensured it imports and call_begin passes. 2. Fixup the 'test__init__.py' file to now be working again. --- cloudinit/handlers/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py index 94cb699e..20a822bd 100644 --- a/cloudinit/handlers/__init__.py +++ b/cloudinit/handlers/__init__.py @@ -135,12 +135,15 @@ def walker_handle_handler(pdata, _ctype, _filename, payload): modfname = "%s.py" % (modfname) # TODO: Check if path exists?? util.write_file(modfname, payload, 0600) - pdata['handlercount'] = curcount + 1 handlers = pdata['handlers'] try: mod = fixup_handler(importer.import_module(modname)) - handlers.register(mod) call_begin(mod, pdata['data'], frequency) + # Only register and increment + # after the above have worked (so we don't if it + # fails) + handlers.register(mod) + pdata['handlercount'] = curcount + 1 except: util.logexc(LOG, ("Failed at registering python file: %s" " (part handler %s)"), modfname, curcount) -- cgit v1.2.3