Skip to content

Commit 3144d54

Browse files
refining the capture_output_stream script to allow standalone execution
1 parent 28ba05d commit 3144d54

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
appnope==0.1.3
22
asttokens==2.2.1
3-
asyncio==3.4.3
43
attrs==23.1.0
54
backcall==0.2.0
65
black==23.7.0
@@ -27,7 +26,6 @@ iniconfig==2.0.0
2726
ipykernel==6.24.0
2827
ipython==8.14.0
2928
isort==5.12.0
30-
janus==1.0.0
3129
jedi==0.18.2
3230
jsonschema==4.18.4
3331
jsonschema-specifications==2023.7.1
@@ -54,7 +52,6 @@ pyasn1==0.5.0
5452
pyasn1-modules==0.3.0
5553
Pygments==2.15.1
5654
pytest==7.4.0
57-
pytest-asyncio==0.21.1
5855
pytest-dependency==0.5.1
5956
python-dateutil==2.8.2
6057
pyzmq==25.1.0

tests/capture_output_stream.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
import time
78
from jupyter_client.blocking.client import BlockingKernelClient
89
from watchdog.observers import Observer
910
from watchdog.events import FileSystemEventHandler
@@ -113,7 +114,20 @@ def start_watches():
113114

114115

115116
def main():
116-
start_watches()
117+
logging.basicConfig(
118+
level=logging.INFO, format="%(levelname)s:%(name)s:%(message)s"
119+
) # Configure logging here
120+
threads, stop_event = start_watches()
121+
122+
try:
123+
while True: # Keep the script running
124+
time.sleep(1)
125+
except KeyboardInterrupt:
126+
stop_event.set() # Signal the threads to stop
127+
for thread in threads:
128+
thread.join() # Wait for all threads to finish
129+
130+
print("Exiting...")
117131

118132

119133
if __name__ == "__main__":

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import logging
1111
from capture_output_stream import start_watches
1212

13-
logging.basicConfig(level=logging.INFO, format="%(levelname)s:%(name)s:%(message)s")
13+
logging.basicConfig(level=logging.INFO, format="%(levelname)s:%(name)s: %(message)s")
1414
logger = logging.getLogger(__name__)
1515

1616

0 commit comments

Comments
 (0)