Skip to content

Commit 4f793fa

Browse files
committed
Add progress indicators when spawning
- Uses JupyterHub 0.9 feature, no effect for <0.9. - Closes: #81
1 parent 35b7afd commit 4f793fa

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ install:
3030
- pip install attrs>17.4.0
3131
- pip install --pre -r jupyterhub/dev-requirements.txt
3232
- pip install --pre -e jupyterhub
33+
- pip install --pre -f travis-wheels/wheelhouse -r requirements.txt
3334

3435
script:
3536
- travis_retry py.test --lf --cov batchspawner batchspawner/tests -v

batchspawner/batchspawner.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
* remote execution via submission of templated scripts
1616
* job names instead of PIDs
1717
"""
18+
import asyncio
19+
from async_generator import async_generator, yield_, yield_from_
1820
import pwd
1921
import os
2022
import re
23+
import sys
2124

2225
import xml.etree.ElementTree as ET
2326

@@ -411,6 +414,23 @@ def stop(self, now=False):
411414
self.job_id, self.current_ip, self.port)
412415
)
413416

417+
@async_generator
418+
async def progress(self):
419+
while True:
420+
if self.state_ispending():
421+
await yield_({
422+
"message": "Pending in queue...",
423+
})
424+
elif self.state_isrunning():
425+
await yield_({
426+
"message": "Cluster job running... waiting to connect",
427+
})
428+
return
429+
else:
430+
await yield_({
431+
"message": "Unknown status...",
432+
})
433+
await gen.sleep(.1)
414434

415435
class BatchSpawnerRegexStates(BatchSpawnerBase):
416436
"""Subclass of BatchSpawnerBase that uses config-supplied regular expressions

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
async_generator>=1.8
12
jinja2
23
jupyterhub>=0.5

0 commit comments

Comments
 (0)