Skip to content

Commit 3e16808

Browse files
committed
A bit of cleanup and a warning for the future
1 parent 307820f commit 3e16808

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/psij/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,17 @@ def flush(self) -> None:
162162
# Ensures that, upon return from this call, all updates available before this call have
163163
# been processed. To do so, we send a UDP packet to the socket to wake it up and wait until
164164
# it is received. This does not guarantee that file-based updates are necessarily
165-
# processes, since that depends on many factors.
165+
# processed, since that depends on many factors.
166+
# On the minus side, this method, as implemented, can cause deadlocks if the socket
167+
# reads fail for unexpected reasons. This should probably be accounted for.
166168
token = '_SYNC ' + str(random.getrandbits(128))
167169
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
168170
sock.sendto(bytes(token, 'utf-8'), ('127.0.0.1', self.update_port))
169171
delay = 0.0001
170172
while token not in self._sync_ids:
171173
time.sleep(delay)
172174
delay *= 2
175+
self._sync_ids.remove(token)
173176

174177
def _process_update_data(self, data: bytes) -> None:
175178
sdata = data.decode('utf-8')

0 commit comments

Comments
 (0)