Skip to content

Commit

Permalink
Better handling of requests connection to detect bokeh serve
Browse files Browse the repository at this point in the history
close issue#13

Signed-off-by: Christian Tremblay <[email protected]>
  • Loading branch information
ChristianTremblay committed Jan 13, 2016
1 parent 1852455 commit 4e455bc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ install:
- pip install coveralls
- pip install nose
script:
- nosetests --with-coverage --cover-package=BAC0 -v
- nosetests --with-coverage --cover-package=pyhaystack -v
after_success: coveralls

deploy:
Expand Down
2 changes: 1 addition & 1 deletion BAC0/infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
__email__ = '[email protected]'
__url__ = 'https://github.com/ChristianTremblay/BAC0'
__download_url__ = 'https://github.com/ChristianTremblay/BAC0/archive/master.zip'
__version__ = '0.98a1'
__version__ = '0.98a2'
__license__ = 'LGPLv3'
21 changes: 14 additions & 7 deletions BAC0/scripts/ReadWriteScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,30 @@ def __init__(self, ip=None):

def start_bokeh(self):
try:
print('Starting Bokeh Serve')
logging.getLogger("requests").setLevel(logging.INFO)
self.BokehServer = BokehServer()
self.BokehServer.start()
attemptedConnections = 0
while True:
try:
requests.get('http://localhost:5006')
break
except requests.exceptions.ConnectionError:
attemptedConnections += 1
if attemptedConnections > 10:
raise BokehServerCantStart
time.sleep(1)

self.bokehserver = True
self.bokeh_document = BokehDocument(title = 'BAC0 - Live Trending')
self.new_bokeh_session()
self.bokeh_session.loop()
attemptedConnections = 0
while requests.get('http://localhost:5006').status_code != 200:
time.sleep(0.1)
attemptedConnections += 1
if attemptedConnections > 10:
raise BokehServerCantStart
self.bokehserver = True
except OSError as error:
self.bokehserver = False
print('Please start bokeh serve to use trending features')
print('controller.chart will not work')
print(error)
except RuntimeError as rterror:
self.bokehserver = False
print('Server already running')
Expand Down

0 comments on commit 4e455bc

Please sign in to comment.