Skip to content

Commit 62389e2

Browse files
msosyakCarl Keene
authored andcommitted
[docker-database] Fix Python3 issue (sonic-net#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
1 parent db78661 commit 62389e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dockers/docker-database/flush_unused_database

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import subprocess
55
import time
66

77
while(True):
8-
output = subprocess.Popen(['sonic-db-cli', 'PING'], stdout=subprocess.PIPE).communicate()[0]
8+
output = subprocess.Popen(['sonic-db-cli', 'PING'], stdout=subprocess.PIPE, text=True).communicate()[0]
99
if 'PONG' in output:
1010
break
1111
time.sleep(1)

0 commit comments

Comments
 (0)