[PATCH RFC 14/32] python//qmp.py: use True/False for non/blocking modes

John Snow posted 32 patches 5 years, 6 months ago
Maintainers: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Fam Zheng <fam@euphon.net>, Eduardo Habkost <ehabkost@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Markus Armbruster <armbru@redhat.com>, Max Reitz <mreitz@redhat.com>, Cleber Rosa <crosa@redhat.com>
[PATCH RFC 14/32] python//qmp.py: use True/False for non/blocking modes
Posted by John Snow 5 years, 6 months ago
The type system doesn't want integers.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/qemu/lib/qmp.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/qemu/lib/qmp.py b/python/qemu/lib/qmp.py
index b91c9d5c1c..a634c4e26c 100644
--- a/python/qemu/lib/qmp.py
+++ b/python/qemu/lib/qmp.py
@@ -120,14 +120,14 @@ def __get_events(self, wait=False):
         """
 
         # Check for new events regardless and pull them into the cache:
-        self.__sock.setblocking(0)
+        self.__sock.setblocking(False)
         try:
             self.__json_read()
         except OSError as err:
             if err.errno == errno.EAGAIN:
                 # No data available
                 pass
-        self.__sock.setblocking(1)
+        self.__sock.setblocking(True)
 
         # Wait for new events, if needed.
         # if wait is 0.0, this means "no wait" and is also implicitly false.
-- 
2.21.1


Re: [PATCH RFC 14/32] python//qmp.py: use True/False for non/blocking modes
Posted by Philippe Mathieu-Daudé 5 years, 6 months ago
On 5/14/20 7:53 AM, John Snow wrote:
> The type system doesn't want integers.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>   python/qemu/lib/qmp.py | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/python/qemu/lib/qmp.py b/python/qemu/lib/qmp.py
> index b91c9d5c1c..a634c4e26c 100644
> --- a/python/qemu/lib/qmp.py
> +++ b/python/qemu/lib/qmp.py
> @@ -120,14 +120,14 @@ def __get_events(self, wait=False):
>           """
>   
>           # Check for new events regardless and pull them into the cache:
> -        self.__sock.setblocking(0)
> +        self.__sock.setblocking(False)
>           try:
>               self.__json_read()
>           except OSError as err:
>               if err.errno == errno.EAGAIN:
>                   # No data available
>                   pass
> -        self.__sock.setblocking(1)
> +        self.__sock.setblocking(True)
>   
>           # Wait for new events, if needed.
>           # if wait is 0.0, this means "no wait" and is also implicitly false.
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Re: [PATCH RFC 14/32] python//qmp.py: use True/False for non/blocking modes
Posted by Philippe Mathieu-Daudé 5 years, 5 months ago
On 5/14/20 7:53 AM, John Snow wrote:
> The type system doesn't want integers.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  python/qemu/lib/qmp.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/python/qemu/lib/qmp.py b/python/qemu/lib/qmp.py
> index b91c9d5c1c..a634c4e26c 100644
> --- a/python/qemu/lib/qmp.py
> +++ b/python/qemu/lib/qmp.py
> @@ -120,14 +120,14 @@ def __get_events(self, wait=False):
>          """
>  
>          # Check for new events regardless and pull them into the cache:
> -        self.__sock.setblocking(0)
> +        self.__sock.setblocking(False)
>          try:
>              self.__json_read()
>          except OSError as err:
>              if err.errno == errno.EAGAIN:
>                  # No data available
>                  pass
> -        self.__sock.setblocking(1)
> +        self.__sock.setblocking(True)
>  
>          # Wait for new events, if needed.
>          # if wait is 0.0, this means "no wait" and is also implicitly false.
> 

Thanks, applied to my python-next tree:
https://gitlab.com/philmd/qemu/commits/python-next