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: except:
PIDFILE = 'pid' PIDFILE = 'pid'
try: try:
IP = cp.get("General","IP") LOCAL_IP = cp.get("General","LOCAL_IP")
except: except:
IP = '127.0.0.1' LOCAL_IP = '127.0.0.1'
try: try:

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

Loading…
Cancel
Save