From 75fad02a28eaca12f67c9ea7ac78894b17e4858d Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 8 Jul 2019 01:02:39 -0700 Subject: [PATCH] subchannel: queue pending opens with a deque(), not a list slightly cleaner --- src/wormhole/_dilation/subchannel.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/wormhole/_dilation/subchannel.py b/src/wormhole/_dilation/subchannel.py index bcdff6a..32c9cff 100644 --- a/src/wormhole/_dilation/subchannel.py +++ b/src/wormhole/_dilation/subchannel.py @@ -1,4 +1,5 @@ import six +from collections import deque from attr import attrs, attrib from attr.validators import instance_of, provides from zope.interface import implementer @@ -269,9 +270,9 @@ class SubchannelListenerEndpoint(object): def __attrs_post_init__(self): self._factory = None - self._pending_opens = [] + self._pending_opens = deque() - # from manager + # from manager (actually Inbound) def _got_open(self, t, peer_addr): if self._factory: self._connect(t, peer_addr) @@ -287,9 +288,9 @@ class SubchannelListenerEndpoint(object): def listen(self, protocolFactory): self._factory = protocolFactory - for (t, peer_addr) in self._pending_opens: + while self._pending_opens: + (t, peer_addr) = self._pending_opens.popleft() self._connect(t, peer_addr) - self._pending_opens = [] lp = SubchannelListeningPort(self._host_addr) return succeed(lp)