[docker-database] Fix Python3 issue (#7700)
#### Why I did it To avoid the following error ``` Traceback (most recent call last): File "/usr/local/bin/flush_unused_database", line 10, in <module> if 'PONG' in output: TypeError: a bytes-like object is required, not 'str' ``` `communicate` method returns the strings if streams were opened in text mode; otherwise, bytes. In our case text arg in Popen is not true and that means that `communicate` return the bytes #### How I did it Set `text=True` to get strings instead of bytes #### How to verify it run `/usr/local/bin/flush_unused_database` inside database container
This commit is contained in:
parent
3bb123930b
commit
3bf60b3db2
@ -5,7 +5,7 @@ import subprocess
|
||||
import time
|
||||
|
||||
while(True):
|
||||
output = subprocess.Popen(['sonic-db-cli', 'PING'], stdout=subprocess.PIPE).communicate()[0]
|
||||
output = subprocess.Popen(['sonic-db-cli', 'PING'], stdout=subprocess.PIPE, text=True).communicate()[0]
|
||||
if 'PONG' in output:
|
||||
break
|
||||
time.sleep(1)
|
||||
|
Reference in New Issue
Block a user