Commit f9991e58 authored by Julien Muchembled's avatar Julien Muchembled

Add support for writeable selectable objects

parent 3e207f4d
...@@ -102,7 +102,7 @@ def main(): ...@@ -102,7 +102,7 @@ def main():
server_dict[r.fileno()] = r._handle_request_noblock server_dict[r.fileno()] = r._handle_request_noblock
if server_dict: if server_dict:
while True: while True:
args = server_dict.copy(), [] args = server_dict.copy(), {}, []
server.select(*args) server.select(*args)
utils.select(*args) utils.select(*args)
......
...@@ -90,7 +90,7 @@ class RegistryServer(object): ...@@ -90,7 +90,7 @@ class RegistryServer(object):
self.email = self.ca.get_subject().emailAddress self.email = self.ca.get_subject().emailAddress
self.onTimeout() self.onTimeout()
def select(self, r, t): def select(self, r, w, t):
if self.timeout: if self.timeout:
t.append((self.timeout, self.onTimeout)) t.append((self.timeout, self.onTimeout))
......
...@@ -186,7 +186,7 @@ class TunnelManager(object): ...@@ -186,7 +186,7 @@ class TunnelManager(object):
self._free_iface_list.append(iface) self._free_iface_list.append(iface)
del self._iface_to_prefix[iface] del self._iface_to_prefix[iface]
def select(self, r, t): def select(self, r, w, t):
r[self._read_pipe] = self.handleTunnelEvent r[self._read_pipe] = self.handleTunnelEvent
r[self.sock] = self.handlePeerEvent r[self.sock] = self.handlePeerEvent
t.append((self._next_refresh, self.refresh)) t.append((self._next_refresh, self.refresh))
......
...@@ -28,7 +28,7 @@ class Forwarder(object): ...@@ -28,7 +28,7 @@ class Forwarder(object):
raise UPnPException(str(e)) raise UPnPException(str(e))
return wraps(wrapped)(wrapper) return wraps(wrapped)(wrapper)
def select(self, r, t): def select(self, r, w, t):
t.append((self.next_refresh, self.refresh)) t.append((self.next_refresh, self.refresh))
def checkExternalIp(self, ip=None): def checkExternalIp(self, ip=None):
......
...@@ -165,9 +165,9 @@ class Popen(subprocess.Popen): ...@@ -165,9 +165,9 @@ class Popen(subprocess.Popen):
return r return r
def select(R, T): def select(R, W, T):
try: try:
r, w, _ = _select.select(R, (), (), r, w, _ = _select.select(R, W, (),
max(0, min(T)[0] - time.time()) if T else None) max(0, min(T)[0] - time.time()) if T else None)
except _select.error as e: except _select.error as e:
if e.args[0] != errno.EINTR: if e.args[0] != errno.EINTR:
...@@ -175,6 +175,8 @@ def select(R, T): ...@@ -175,6 +175,8 @@ def select(R, T):
return return
for r in r: for r in r:
R[r]() R[r]()
for w in w:
W[w]()
t = time.time() t = time.time()
for next_refresh, refresh in T: for next_refresh, refresh in T:
if next_refresh <= t: if next_refresh <= t:
......
...@@ -425,7 +425,7 @@ def main(): ...@@ -425,7 +425,7 @@ def main():
raise ReexecException("Restart to renew certificate") raise ReexecException("Restart to renew certificate")
select_list.append(utils.select) select_list.append(utils.select)
while True: while True:
args = {}, [(next_renew, renew)] args = {}, {}, [(next_renew, renew)]
for s in select_list: for s in select_list:
s(*args) s(*args)
finally: finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment