From b275c51a6fcf85d69af4e1ae7ee3d3918db8850b Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 9 Dec 2014 15:52:14 -0800 Subject: [PATCH] Just assign a empty collection instead of copy/clear Instead of copying the '_events_listeners' then clear them to get a clean copy just set the copies '_events_listeners' to a new collection in the first place. Change-Id: I17d4f02241c90a49fc4334cfd1f2fffd03d58927 --- taskflow/task.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/taskflow/task.py b/taskflow/task.py index c34a13bf..26141775 100644 --- a/taskflow/task.py +++ b/taskflow/task.py @@ -145,8 +145,7 @@ class BaseTask(atom.Atom): :return: the copied task """ c = copy.copy(self) - c._events_listeners = c._events_listeners.copy() - c._events_listeners.clear() + c._events_listeners = collections.defaultdict(list) if retain_listeners: for event_name, listeners in six.iteritems(self._events_listeners): c._events_listeners[event_name] = listeners[:]