|
51 | 51 | # 2006 MySQL server has gone away
|
52 | 52 | MYSQL_EXPECTED_ERROR_CODES = [2013, 2006]
|
53 | 53 |
|
| 54 | +PYMYSQL_VERSION_LT_06 = Version(pymysql.__version__) < Version("0.6") |
| 55 | + |
54 | 56 |
|
55 | 57 | class ReportSlave(object):
|
56 | 58 | """Represent the values that you may report when connecting as a slave
|
@@ -330,7 +332,7 @@ def _register_slave(self):
|
330 | 332 |
|
331 | 333 | packet = self.report_slave.encoded(self.__server_id)
|
332 | 334 |
|
333 |
| - if Version(pymysql.__version__) < Version("0.6"): |
| 335 | + if PYMYSQL_VERSION_LT_06: |
334 | 336 | self._stream_connection.wfile.write(packet)
|
335 | 337 | self._stream_connection.wfile.flush()
|
336 | 338 | self._stream_connection.read_packet()
|
@@ -502,7 +504,7 @@ def __connect_to_stream(self):
|
502 | 504 | # encoded_data
|
503 | 505 | prelude += gtid_set.encoded()
|
504 | 506 |
|
505 |
| - if Version(pymysql.__version__) < Version("0.6"): |
| 507 | + if PYMYSQL_VERSION_LT_06: |
506 | 508 | self._stream_connection.wfile.write(prelude)
|
507 | 509 | self._stream_connection.wfile.flush()
|
508 | 510 | else:
|
@@ -588,7 +590,7 @@ def fetchone(self):
|
588 | 590 | self.__connect_to_ctl()
|
589 | 591 |
|
590 | 592 | try:
|
591 |
| - if Version(pymysql.__version__) < Version("0.6"): |
| 593 | + if PYMYSQL_VERSION_LT_06: |
592 | 594 | pkt = self._stream_connection.read_packet()
|
593 | 595 | else:
|
594 | 596 | pkt = self._stream_connection._read_packet()
|
|
0 commit comments