Skip to content

Commit 36e40c5

Browse files
Merge pull request julien-duponchelle#11 from bjoernhaeuser/master
Minor adjustments
2 parents 9144e8c + 8de98ef commit 36e40c5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pymysqlreplication/binlogstream.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class BinLogStreamReader(object):
1212
'''Connect to replication stream and read event'''
1313

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):
1515
'''
1616
resume_stream: Start for latest event of binlog or from older available event
1717
blocking: Read on stream is blocking
@@ -45,6 +45,7 @@ def __connect_to_ctl(self):
4545
self._ctl_connection_settings['db'] = 'information_schema'
4646
self._ctl_connection_settings['cursorclass'] = pymysql.cursors.DictCursor
4747
self._ctl_connection = pymysql.connect(**self._ctl_connection_settings)
48+
self.__connected_ctl = True
4849

4950
def __connect_to_stream(self):
5051
self._stream_connection = pymysql.connect(**self.__connection_settings)
@@ -61,7 +62,7 @@ def __connect_to_stream(self):
6162
# binlog-filename (string.EOF) -- filename of the binlog on the master
6263
command = COM_BINLOG_DUMP
6364
prelude = struct.pack('<i', len(self.__log_file) + 11) \
64-
+ int2byte(command)
65+
+ int2byte(command)
6566
if self.__log_pos is None:
6667
if self.__resume_stream:
6768
prelude += struct.pack('<I', log_pos)
@@ -80,9 +81,9 @@ def __connect_to_stream(self):
8081

8182
def fetchone(self):
8283
while True:
83-
if self.__connected_stream == False:
84+
if not self.__connected_stream:
8485
self.__connect_to_stream()
85-
if self.__connected_ctl == False:
86+
if not self.__connected_ctl:
8687
self.__connect_to_ctl()
8788
pkt = None
8889
try:

pymysqlreplication/event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection):
4747
def dump(self):
4848
print("=== %s ===" % (self.__class__.__name__))
4949
print("Position: %d" % self.position)
50-
print("Next binlog file: %d" % self.next_binlog)
50+
print("Next binlog file: %s" % self.next_binlog)
5151
print()
5252

5353

0 commit comments

Comments
 (0)