Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #96 from bennytheshap/develop
Browse files Browse the repository at this point in the history
pick port at random so that we can run multiple ouimeaux scripts at once
  • Loading branch information
iancmcc committed Aug 12, 2015
2 parents fcdb924 + 791eae6 commit 28c48fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ouimeaux/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from ouimeaux.device.maker import Maker
from ouimeaux.signals import subscription

from random import randint



log = logging.getLogger(__name__)

Expand All @@ -22,6 +25,8 @@ class SubscriptionRegistry(object):
def __init__(self):
self._devices = {}
self._callbacks = defaultdict(list)
self.port = randint(8300, 8990)


def register(self, device):
if not device:
Expand All @@ -41,7 +46,7 @@ def _resubscribe(self, url, sid=None):
else:
host = get_ip_address()
headers.update({
"CALLBACK": '<http://%s:8989>' % host,
"CALLBACK": '<http://%s:%d>'%(host, self.port),
"NT": "upnp:event"
})
response = requests_request(method="SUBSCRIBE", url=url,
Expand Down Expand Up @@ -93,7 +98,6 @@ def server(self):
"""
server = getattr(self, "_server", None)
if server is None:
server = WSGIServer(('', 8989), self._handle, log=None)
server = WSGIServer(('', self.port), self._handle, log=None)
self._server = server
return server

0 comments on commit 28c48fa

Please sign in to comment.