| Conditions | 7 |
| Total Lines | 28 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | """ |
||
| 39 | def _send_data(self): |
||
| 40 | # Get the data |
||
| 41 | data = self.get_frame() |
||
| 42 | |||
| 43 | # Attempt to send data max 5 times |
||
| 44 | # Thanks to Dave Hocker (pyudmx author) for giving me this solution to the random usb errors |
||
| 45 | success = False |
||
| 46 | retry_count = 0 |
||
| 47 | while not success: |
||
| 48 | try: |
||
| 49 | self.udmx.send_multi_value(1, data) |
||
| 50 | success = True |
||
| 51 | except Exception as e: |
||
| 52 | retry_count += 1 |
||
| 53 | if retry_count > 5: |
||
| 54 | |||
| 55 | # Attempt to reconnect and then send data max 2 times |
||
| 56 | success_reconn = False |
||
| 57 | retry_count_reconn = 0 |
||
| 58 | while not success_reconn: |
||
| 59 | try: |
||
| 60 | self.__connect() |
||
| 61 | self.udmx.send_multi_value(1, data) |
||
| 62 | success_reconn = True |
||
| 63 | except Exception: |
||
| 64 | retry_count_reconn += 1 |
||
| 65 | if retry_count_reconn > 2: |
||
| 66 | raise e |
||
| 67 |