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