Skip to content

Commit d26c598

Browse files
attempting to use daemonized threads instead
1 parent 7eaa651 commit d26c598

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/capture_output_stream.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import re
1010
import threading
1111
import time
12-
from queue import Queue
12+
from queue import Queue, Empty
1313

1414
from jupyter_client.blocking.client import BlockingKernelClient
1515
from watchdog.events import FileSystemEventHandler
@@ -60,11 +60,16 @@ def watch_kernel(connection_file, stop_event):
6060

6161
def watch_queue(queue, watched_files, stop_event):
6262
while not stop_event.is_set():
63-
new_file = queue.get()
64-
if new_file not in watched_files:
65-
logger.debug(f"Processing new kernel: {new_file}")
66-
watched_files.add(new_file)
67-
threading.Thread(target=watch_kernel, args=(new_file, stop_event)).start()
63+
try:
64+
new_file = queue.get()
65+
if new_file not in watched_files:
66+
logger.debug(f"Processing new kernel: {new_file}")
67+
watched_files.add(new_file)
68+
threading.Thread(
69+
target=watch_kernel, args=(new_file, stop_event)
70+
).start()
71+
except Empty:
72+
continue
6873

6974

7075
def start_watches():
@@ -94,6 +99,7 @@ def start_watches():
9499
stop_event,
95100
),
96101
)
102+
watch_thread.daemon = True
97103
watch_thread.start()
98104
threads.append(watch_thread)
99105

tests/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
import os
33
import subprocess
44

5-
import google.auth
65
import pytest
76
from capture_output_stream import start_watches
8-
from google.auth.transport.requests import Request
97
from google.cloud import storage
108
from testbook import testbook
119
from testbook.testbook import TestbookNotebookClient

0 commit comments

Comments
 (0)