Merge pull request #73 from balloob/nmap-lock

Improve NMAP lock issues
This commit is contained in:
Paulus Schoutsen 2015-03-26 14:17:09 -07:00
commit 70bce24b0a
2 changed files with 22 additions and 24 deletions

View file

@ -157,7 +157,8 @@ class DeviceTracker(object):
def update_devices(self, now):
""" Update device states based on the found devices. """
self.lock.acquire()
if not self.lock.acquire(False):
return
found_devices = set(dev.upper() for dev in
self.device_scanner.scan_devices())

View file

@ -1,7 +1,6 @@
""" Supports scanning using nmap. """
import logging
from datetime import timedelta, datetime
import threading
from collections import namedtuple
import subprocess
import re
@ -54,7 +53,6 @@ class NmapDeviceScanner(object):
def __init__(self, config):
self.last_results = []
self.lock = threading.Lock()
self.hosts = config[CONF_HOSTS]
minutes = convert(config.get(CONF_HOME_INTERVAL), int, 0)
self.home_interval = timedelta(minutes=minutes)
@ -116,10 +114,9 @@ class NmapDeviceScanner(object):
if not self.success_init:
return False
with self.lock:
_LOGGER.info("Scanning")
options = "-F"
options = "-F --host-timeout 5"
exclude_targets = set()
if self.home_interval:
now = datetime.now()