11
11
class BinLogStreamReader (object ):
12
12
'''Connect to replication stream and read event'''
13
13
14
- def __init__ (self , connection_settings = {}, resume_stream = False , blocking = False , only_events = None , server_id = 255 ):
14
+ def __init__ (self , connection_settings = {}, resume_stream = False , blocking = False , only_events = None , server_id = 255 ):
15
15
'''
16
16
resume_stream: Start for latest event of binlog or from older available event
17
17
blocking: Read on stream is blocking
@@ -45,6 +45,7 @@ def __connect_to_ctl(self):
45
45
self ._ctl_connection_settings ['db' ] = 'information_schema'
46
46
self ._ctl_connection_settings ['cursorclass' ] = pymysql .cursors .DictCursor
47
47
self ._ctl_connection = pymysql .connect (** self ._ctl_connection_settings )
48
+ self .__connected_ctl = True
48
49
49
50
def __connect_to_stream (self ):
50
51
self ._stream_connection = pymysql .connect (** self .__connection_settings )
@@ -61,7 +62,7 @@ def __connect_to_stream(self):
61
62
# binlog-filename (string.EOF) -- filename of the binlog on the master
62
63
command = COM_BINLOG_DUMP
63
64
prelude = struct .pack ('<i' , len (self .__log_file ) + 11 ) \
64
- + int2byte (command )
65
+ + int2byte (command )
65
66
if self .__log_pos is None :
66
67
if self .__resume_stream :
67
68
prelude += struct .pack ('<I' , log_pos )
@@ -80,9 +81,9 @@ def __connect_to_stream(self):
80
81
81
82
def fetchone (self ):
82
83
while True :
83
- if self .__connected_stream == False :
84
+ if not self .__connected_stream :
84
85
self .__connect_to_stream ()
85
- if self .__connected_ctl == False :
86
+ if not self .__connected_ctl :
86
87
self .__connect_to_ctl ()
87
88
pkt = None
88
89
try :
0 commit comments