示例#1
0
def test_start_new_thread3():
    from time import sleep
    global value
    value = 0

    def func():
        global value
        value = 5

    new_thread(func)

    sleep(0.01)
    assert value == 5
示例#2
0
 def resume_acquisition(self):
     """
     """
     from ubcs_auxiliary.multithreading import new_thread
     if not self.acquiring:
         self.acquiring = True
         self.threads['acquisition'] = new_thread(self.run)
示例#3
0
def test_start_new_thread2():
    from time import sleep
    global sum_value
    global kwargs_list

    def func(*args, **kwargs):
        global sum_value
        global kwargs_list
        from numpy import sum
        sum_value = sum(args)
        kwargs_list = list(kwargs.keys())

    sum_value = None
    kwargs_list = None
    new_thread(func, -1, -2, -3, -4, -5, -6, keyword12='', keyword22=5)
    while kwargs_list is None:
        sleep(0.01)
    assert sum_value == -21
    assert kwargs_list == ['keyword12', 'keyword22']
示例#4
0
    def recording_start(self):
        """
        a simple wrapper to start a recording_run loop in a separate thread.

        stops recording threads if such are active.
        resets queue to insure we save only new data.
        """
        from ubcs_auxiliary.multithreading import new_thread
        from time import time, sleep
        if self.recording:
            self.recording_stop()
            sleep(1)
        self.queue.reset()
        self.recording = True
        self.threads['recording'] = new_thread(self.recording_run)
示例#5
0
def test_start_new_thread():
    print('1')

    def func(*args, **kwargs):
        global sum_value
        global kwargs_list
        from numpy import sum
        sum_value = sum(args)
        kwargs_list = list(kwargs.keys())

    from time import sleep
    global sum_value
    global kwargs_list
    sum_value = None
    kwargs_list = None
    thread = new_thread(func, 1, 2, 3, 4, 5, 6, keyword1='', keyword2=5)
    while kwargs_list is None:
        sleep(0.01)
    assert sum_value == 21
    assert kwargs_list == ['keyword1', 'keyword2']
 def start(self):
     from ubcs_auxiliary.multithreading import new_thread
     new_thread(self.run)
示例#7
0
 def start(self):
     """
     start the while running=True loop(function run()) in a separate thread.
     """
     from ubcs_auxiliary.multithreading import new_thread
     self.threads['running'] = new_thread(self.run)
示例#8
0
 def start_thread(self):
     from ubcs_auxiliary.multithreading import new_thread
     if not self.acquiring:
         self.start_acquisition()
         self.threads['acquisition'] = new_thread(self.run)
 def recording_start(self):
     from ubcs_auxiliary.multithreading import new_thread
     self.recording = True
     new_thread(self.recording_run)
 def start(self):
     from ubcs_auxiliary.multithreading import new_thread
     self.camera.start_thread()
     new_thread(self.run)