Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mockmodel.py: unsubscribing from 'exit' channel on cleanup
The function virtviewertmpfile_cleanup executes the cleanup of the temporary file that the virt viewer mockmodel uses. For each instance of the Mockmodel class, a new file is created and needs cleanup. When running the unit tests in WoK, this function gives an error saying that the file doesn't exist. Further investigation showed that the same cleanup function was being called multiple times, causing this error. This happens because the cherrypy 'exit' channel is process wide and its subscribers are kept in subsequent calls of cherrypy.engine.exit(). This scenario is common when running the current WoK tests, which creates multiple server instances in the same process. The sitation before this patch can be exemplified as follows: - Server A is instanced. The function 'cleanA' is subscribed in the Cherrypy 'exit' channel; - Server A exits. 'cleanA' is executed but it is not unsubscribed from the 'exit' channel; - A new server B is instanced. A function 'cleanB' is subscribed in the 'exit' channel; - Server B exits. A message is sent to all subscribers of the 'exit' channel. 'cleanA' is called again and throws an error because there is nothing else to clean up from the previous server A. Making the cleanup function unsubscribe itself from the 'exit' channel solves the issue. This fixes WoK bug kimchi-project/wok#183 Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
- Loading branch information