cros/cryptohome.py: move signal data clearing _before_ async calls

Ensure that received signal data is not cleared after a call has been
issued.  There is a risk that a fast response from cryptohome will be
cleared from the signal data before the test attempts to process it.

TEST=none yet
BUG=chromium:367278

Change-Id: Icf3101847d704d99c8765990fcd2f3a05fc12e80
Reviewed-on: https://chromium-review.googlesource.com/201372
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Commit-Queue: Will Drewry <wad@chromium.org>
Tested-by: Will Drewry <wad@chromium.org>
diff --git a/client/cros/cryptohome.py b/client/cros/cryptohome.py
index 10933d8..ea6fb8d 100644
--- a/client/cros/cryptohome.py
+++ b/client/cros/cryptohome.py
@@ -332,7 +332,6 @@
       """Wait for the |signal| with matching |data|
          Returns the resulting dict on success or {} on error.
       """
-      self.clear_signal_content(signal)
       # Do not bubble up the timeout here, just return {}.
       result = {}
       try:
@@ -348,6 +347,8 @@
     # Perform a data-less async call.
     # TODO(wad) Add __async_data_call.
     def __async_call(self, method, *args):
+        # Clear out any superfluous async call signals.
+        self.clear_signal_content(self.ASYNC_CALL_STATUS_SIGNAL)
         out = self.__call(method, *args)
         logging.debug('Issued call ' + str(method) +
                       ' with async_id ' + str(out))