[Kimchi-devel] [PATCH] Fix: accelerate mockmodel for file upload

Crístian Viana vianac at linux.vnet.ibm.com
Thu Sep 25 13:46:09 UTC 2014


On 25-09-2014 08:12, lvroyce at linux.vnet.ibm.com wrote:
> -                data = upload_file.file.read(8192)
> +                data = upload_file.file.read(8192*32)
>                   if not data:
>                           break
>                   size += len(data)

The variable "data" doesn't seem to be used anywhere else after 
receiving data from the upload file. So why are we even reading it? 
Can't we skip the reading operation completely and just store the 
"volume"? It's a mock environment.

> diff --git a/tests/test_rest.py b/tests/test_rest.py
> index 7eb6233..fa44985 100644
> --- a/tests/test_rest.py
> +++ b/tests/test_rest.py
> @@ -1948,8 +1948,10 @@ class RestTests(unittest.TestCase):
>               self.assertEquals(r.status_code, 202)
>               task = r.json()
>               self._wait_task(task['id'])
> +            time.sleep(5)

The function "_wait_task" has an optional parameter which selects the 
maximum time it will wait for the task, in seconds. Its default value is 
5. If you need to wait another 5 seconds, I'd suggest using:

self._wait_task(task['id'], 10)

rather than adding another sleep command.

But I guess this won't be necessary if we skip reading the file as I 
suggested above.




More information about the Kimchi-devel mailing list