Skip to content

Commit

Permalink
🐛 Address a hang in newer versions of Live when the UDP port is alrea…
Browse files Browse the repository at this point in the history
…dy being used
  • Loading branch information
leolabs committed Sep 10, 2023
1 parent ac02271 commit 5caeaeb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions midi-script/Socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import zlib
import os
import tempfile
from threading import Timer

from .Logging import logger

Expand Down Expand Up @@ -36,6 +35,7 @@ def __init__(self, handler):
self._client_addr = ("127.0.0.1", 39031)
self._last_error = ""
self._socket = None
self._chunk_limit = None

self.read_remote_port()
self.init_socket(True)
Expand Down Expand Up @@ -147,14 +147,15 @@ def init_socket(self, try_stored=False):
self.log_error_once(msg + "(Client address: " +
str(self._client_addr) + ")")
self.show_message(msg)
t = Timer(5, self.init_socket)
t = Live.Base.Timer(
callback=self.init_socket, interval=5000, repeat=False)
t.start()

def _sendto(self, msg):
'''Send a raw message to the client, compressed and chunked, if necessary'''
compressed = zlib.compress(msg.encode("utf8")) + b'\n'

if self._socket == None:
if self._socket == None or self._chunk_limit == None:
return

if len(compressed) < self._chunk_limit:
Expand Down

0 comments on commit 5caeaeb

Please sign in to comment.