Skip to content

Commit

Permalink
Start test subprocess from the main thread, using an event queue to c…
Browse files Browse the repository at this point in the history
…oordinate:

* Allow only a single instance of pytest to run at any time
* Queue up filesystem events while the tests are running
* Spool on dequeue instead of enqueue
* Simplify show_summary
  • Loading branch information
joeyespo committed Apr 4, 2016
1 parent ee041d9 commit 0cf6b93
Show file tree
Hide file tree
Showing 3 changed files with 172 additions and 217 deletions.
25 changes: 25 additions & 0 deletions pytest_watch/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import os
import subprocess
import sys
from time import sleep

try:
from queue import Empty
except ImportError:
from Queue import Empty


is_windows = sys.platform == 'win32'
Expand All @@ -21,6 +27,25 @@ def clear():
subprocess.call('cls' if is_windows else 'clear', shell=True)


def dequeue_all(queue, spool=False):
"""
Empties the specified queue into a list, optionally with spool time.
"""
items = []
while True:
try:
while True:
items.append(queue.get_nowait())
except Empty:
# If spooling, wait a moment and check for new items
if spool:
sleep(0.2)
if not queue.empty():
continue
break
return items


def samepath(left, right):
"""
Determines whether two paths are the same.
Expand Down
45 changes: 0 additions & 45 deletions pytest_watch/spooler.py

This file was deleted.

Loading

0 comments on commit 0cf6b93

Please sign in to comment.