commit af7d94d081007e91f80b9ce84aa31b3f1bf97b60
parent ad5bb3c45328867098b60c456410e726ebf28db2
Author: ThomasV <electrumdev@gmail.com>
Date: Tue, 6 Jan 2015 13:15:33 +0100
Merge pull request #939 from Tafelpoot/daemon2
Fix Daemon on Windows
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/daemon.py b/lib/daemon.py
@@ -36,10 +36,11 @@ DAEMON_PORT=8001
def do_start_daemon(config):
import subprocess
logfile = open(os.path.join(config.path, 'daemon.log'),'w')
- p = subprocess.Popen(["python2",__file__], stderr=logfile, stdout=logfile, close_fds=True)
+ p = subprocess.Popen([sys.executable,__file__], stderr=logfile, stdout=logfile, close_fds=(os.name=="posix"))
print_stderr("starting daemon (PID %d)"%p.pid)
+
def get_daemon(config, start_daemon=True):
import socket
daemon_port = config.get('daemon_port', DAEMON_PORT)
@@ -47,7 +48,7 @@ def get_daemon(config, start_daemon=True):
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect(('', daemon_port))
+ s.connect(('localhost', daemon_port))
if not daemon_started:
print_stderr("Connected to daemon on port %d"%daemon_port)
return s
@@ -190,7 +191,7 @@ def daemon_loop(server):
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
daemon_port = server.config.get('daemon_port', DAEMON_PORT)
daemon_timeout = server.config.get('daemon_timeout', 5*60)
- s.bind(('', daemon_port))
+ s.bind(('localhost', daemon_port))
s.listen(5)
s.settimeout(1)
t = time.time()