Util block-error should be fixed

master
Stefan Krulj 14 years ago
parent 8f9c510b5c
commit dc339220c9
  1. 4
      sys/config.py
  2. 10
      sys/util.py

@ -33,9 +33,9 @@ try:
except:
PIDFILE = 'pid'
try:
IP = cp.get("General","IP")
LOCAL_IP = cp.get("General","LOCAL_IP")
except:
IP = '127.0.0.1'
LOCAL_IP = '127.0.0.1'
try:

@ -3,6 +3,7 @@ import select
import socket
import threading
import random
import config
from Queue import Queue, Empty
MAGIC_PACKET = ""
@ -58,12 +59,17 @@ def get_local_ip():
s.bind(('<broadcast>', 8888))
s.setblocking(0)
while True:
result = select.select([s],[],[])
result = select.select([s],[],[],10)
if len(result[0])==0 :
print "Warning using default local ip"
queue.put([config.LOCAL_IP])
break
msg, address = result[0][0].recvfrom(1024)
msg = unicode(msg)
if msg == MAGIC_PACKET:
queue.put(address)
break
queue.put(address)
queue = Queue()
thread = threading.Thread(target=udp_listening_server)

Loading…
Cancel
Save