Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit b425e49

Browse files
committed
typo
1 parent 6806d85 commit b425e49

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

runestone/unittest_base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
import logging
23
import os
34
import sys
45
import platform
@@ -9,6 +10,8 @@
910
from selenium import webdriver
1011
from selenium.webdriver.chrome.options import Options
1112
from pyvirtualdisplay import Display
13+
logging.basicConfig(level=logging.WARN)
14+
mylogger = logging.getLogger()
1215

1316
# Select an unused port for serving web pages to the test suite.
1417
PORT = '8081'
@@ -45,15 +48,17 @@ def setUpModule(self):
4548
self.assertFalse(p.returncode)
4649
# Make sure any older servers on port 8081 are killed -- Windows???
4750
if sys.platform in ("darwin", "linux"):
51+
mylogger.debug("Checking for stale Runestone processes")
4852
process = subprocess.Popen(["lsof", "-i", ":{0}".format(PORT)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
4953
stdout, stderr = process.communicate()
5054
for process in str(stdout.decode("utf-8")).split("\n")[1:]:
5155
data = [x for x in process.split(" ") if x != '']
5256
if (len(data) <= 1):
5357
continue
5458
ptokill = int(data[1])
59+
mylogger.warn("Attempting to kill a stale runestone serve process: {}".format(ptokill))
5560
os.kill(ptokill, signal.SIGKILL)
56-
time.sleep(2)
61+
time.sleep(2) # give the old process a couple seconds to clear out
5762
try:
5863
os.kill(ptokill, 0) # will throw an Error if process gone
5964
pytest.exit("Stale runestone server can't kill process: {}".format(ptokill))
@@ -65,7 +70,6 @@ def setUpModule(self):
6570
except Exception:
6671
pytest.exit("Unknown error while trying to kill stale runestone server")
6772

68-
6973
# Run the server. Simply calling ``runestone serve`` fails, since the process killed isn't the actual server, but probably a setuptools-created launcher.
7074
self.runestone_server = subprocess.Popen([sys.executable, '-m', 'runestone', 'serve', '--port', PORT])
7175

0 commit comments

Comments
 (0)