mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use filesystem instead of stdout for signalling, should fix the problem with OS X buffering causing the test to fail
This commit is contained in:
parent
e32ff0ec67
commit
246bf60c88
@ -9,6 +9,7 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@ -36,7 +37,6 @@ def run_worker(mod, func, **kw):
|
|||||||
exe = [sys.executable, os.path.join(sys.setup_dir, 'run-calibre-worker.py')]
|
exe = [sys.executable, os.path.join(sys.setup_dir, 'run-calibre-worker.py')]
|
||||||
env = kw.get('env', os.environ.copy())
|
env = kw.get('env', os.environ.copy())
|
||||||
env['CALIBRE_SIMPLE_WORKER'] = mod + ':' + func
|
env['CALIBRE_SIMPLE_WORKER'] = mod + ':' + func
|
||||||
env['PYTHONUNBUFFERED'] = '1'
|
|
||||||
if iswindows:
|
if iswindows:
|
||||||
import win32process
|
import win32process
|
||||||
kw['creationflags'] = win32process.CREATE_NO_WINDOW
|
kw['creationflags'] = win32process.CREATE_NO_WINDOW
|
||||||
@ -69,11 +69,12 @@ class IPCLockTest(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_exclusive_file_other_process(self):
|
def test_exclusive_file_other_process(self):
|
||||||
child = run_worker('calibre.utils.test_lock', 'other1', stdout=subprocess.PIPE)
|
child = run_worker('calibre.utils.test_lock', 'other1')
|
||||||
print(1111111111)
|
while child.poll() is None:
|
||||||
ready = child.stdout.readline()
|
if os.path.exists('ready'):
|
||||||
print(2222222222)
|
break
|
||||||
self.assertEqual(ready.strip(), b'ready')
|
time.sleep(0.01)
|
||||||
|
self.assertIsNone(child.poll(), 'child died without creating ready dir')
|
||||||
ef = FastFailEF('test')
|
ef = FastFailEF('test')
|
||||||
self.assertRaises(EnvironmentError, ef.__enter__)
|
self.assertRaises(EnvironmentError, ef.__enter__)
|
||||||
child.kill()
|
child.kill()
|
||||||
@ -83,11 +84,9 @@ class IPCLockTest(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def other1():
|
def other1():
|
||||||
import sys, time
|
|
||||||
e = ExclusiveFile('test')
|
e = ExclusiveFile('test')
|
||||||
with e:
|
with e:
|
||||||
print('ready')
|
os.mkdir('ready')
|
||||||
sys.stdout.flush()
|
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user