From 8df5e7efcebabb76326529c96475cb01a69e2c32 Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Sun, 5 Feb 2006 15:31:31 +0000 Subject: [PATCH] two small errors on win --- src/common/nslookup.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/nslookup.py b/src/common/nslookup.py index 2234c5693..e8df2983a 100644 --- a/src/common/nslookup.py +++ b/src/common/nslookup.py @@ -24,7 +24,7 @@ import sys, os, sre -from xmpp.idlequeue import IdleObject, IdleQueue +from xmpp.idlequeue import * if os.name == 'nt': from subprocess import * elif os.name == 'posix': @@ -205,6 +205,7 @@ class IdleCommand(IdleObject): if self.endtime < self.idlequeue.current_time(): self._return_result() self.pipe.stdout.close() + self.pipe.stdin.close() else: # child is still active, continue to wait self.idlequeue.set_alarm(self.wait_child, 0.1) @@ -230,7 +231,7 @@ class IdleCommand(IdleObject): self.pipe = Popen(self._compose_command_args(), stdout=PIPE, bufsize = 1024, shell = True, stderr = STDOUT, stdin = PIPE) if self.commandtimeout >= 0: - self.endtime = self.idlequeue.current_time() + self.endtime = self.idlequeue.current_time() + self.commandtimeout self.idlequeue.set_alarm(self.wait_child, 0.1) def _start_posix(self): @@ -270,7 +271,7 @@ class IdleCommand(IdleObject): class NsLookup(IdleCommand): def __init__(self, on_result, host='_xmpp-client', type = 'srv'): IdleCommand.__init__(self, on_result) - self.commandtimeout = 30 + self.commandtimeout = 10 self.host = host.lower() self.type = type.lower() if not host_pattern.match(self.host): @@ -296,12 +297,14 @@ class NsLookup(IdleCommand): # TODO: remove below lines if there is nothing more to test if __name__ == '__main__': - if os.name != 'posix': - sys.exit() + if os.name == 'posix': + idlequeue = IdleQueue() + elif os.name == 'nt': + idlequeue = SelectIdleQueue() # testing Resolver class import gobject import gtk - idlequeue = IdleQueue() + resolver = Resolver(idlequeue) def clicked(widget):