Initial import of ORISYS arm workstation
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
from unittest import TestCase
|
||||
from station.processes import ProcessSupervisor
|
||||
from station.tasks import Cancelled
|
||||
|
||||
|
||||
class ProcessesTest(TestCase):
|
||||
def test_owned_process_cancel_and_exit(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
processes=ProcessSupervisor(directory)
|
||||
try:
|
||||
result=processes.run('echo',[sys.executable,'-c','print("completed")'],threading.Event())
|
||||
self.assertTrue(result['ok']);self.assertIn('completed',result['detail'])
|
||||
event=threading.Event();timer=threading.Timer(.2,event.set);timer.start()
|
||||
with self.assertRaises(Cancelled):
|
||||
processes.run('long',[sys.executable,'-c','import time;time.sleep(30)'],event)
|
||||
self.assertFalse(processes.snapshot()['long']['running'])
|
||||
finally: processes.close()
|
||||
Reference in New Issue
Block a user