[Kimchi-devel] [PATCH] [Kimchi] Github #991: unsubscribing from exit bus on cleanup

Aline Manera alinefm at linux.vnet.ibm.com
Mon Aug 29 20:57:17 UTC 2016



On 08/29/2016 05:53 PM, dhbarboza82 at gmail.com wrote:
> From: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
>
> WoK tests are running the Cherrypy Exit bus multiple times
> without executing the __init__ from Mockmodel. causing
> the 'virtviewertmpfile_cleanup' callback to fail because
> there is no temp file created (it was cleaned in a previous
> callback).
>
> Unsubscribing from the 'exit' bus in the cleanup solves the
> issue, given that the subscription only happens in Mockmodel
> __init__ .
>
> Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
> ---
>   mockmodel.py | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mockmodel.py b/mockmodel.py
> index cd06ee3..89f1187 100644
> --- a/mockmodel.py
> +++ b/mockmodel.py
> @@ -33,6 +33,7 @@ from wok.objectstore import ObjectStore
>   from wok.utils import add_task, convert_data_size
>   from wok.xmlutils.utils import xml_item_update
>
> +from wok.plugins.kimchi import config as kimchi_config
>   from wok.plugins.kimchi import imageinfo
>   from wok.plugins.kimchi import osinfo
>   from wok.plugins.kimchi.model import cpuinfo
> @@ -141,7 +142,7 @@ class MockModel(Model):
>           cherrypy.engine.subscribe('exit', self.virtviewertmpfile_cleanup)
>
>       def _create_virt_viewer_tmp_file(self):
> -        path = '../data/virtviewerfiles/'
> +        path = kimchi_config.get_virtviewerfiles_path()
>           if not os.path.isdir(path):
>               os.makedirs(path)
>
> @@ -155,6 +156,7 @@ class MockModel(Model):

>       def virtviewertmpfile_cleanup(self):
>           os.unlink(self.virtviewerfile_tmp.name)
> +        cherrypy.engine.unsubscribe('exit', self.virtviewertmpfile_cleanup)

Why is that needed?

>       def reset(self):
>           MockModel._mock_vms = defaultdict(list)




More information about the Kimchi-devel mailing list