Esempio n. 1
0
async def run_in_main(func_, *args, **kwargs):
    """
    Run and return `func_(*args, **kwargs)` in the kernel's thread.
    Note that this should only be restricted to tkinter calls.
    """
    # Note: the argument is `func_` to prevent name clashes in `kwargs`.
    # This can become a positional only parameter (introduced in Python
    # 3.8) once curio deprecates its usage in Python 3.6 and 3.7.
    async with spawn_thread():
        return AWAIT(_call(func_, args, kwargs))
Esempio n. 2
0
 async def coro1():
     results.append('coro1')
     async with spawn_thread():
         # Calling an async_thread function from a thread context block should
         # work like a normal sync function call
         func1(threading.currentThread())
Esempio n. 3
0
 async def worker2():
     async with spawn_thread():
         AWAIT(evt.wait)
         results.append('worker2')
Esempio n. 4
0
 async def func(x, y):
     async with spawn_thread():
         time.sleep(0.5)
         results.append(AWAIT(simple_coro(x, y)))
Esempio n. 5
0
 async def coro1():
     results.append('coro1')
     async with spawn_thread():
          # Calling an async_thread function from a thread context block should 
          # work like a normal sync function call
          func1(threading.currentThread())
Esempio n. 6
0
 async def worker2():
     async with spawn_thread():
         AWAIT(evt.wait)
         results.append('worker2')
Esempio n. 7
0
 async def func(x, y):
     async with spawn_thread():
         time.sleep(0.5)
         results.append(AWAIT(simple_coro(x, y)))
Esempio n. 8
0
async def run_in_main(func_, *args, **kwargs):
    async with spawn_thread():
        return AWAIT(_run_in_main_helper(func_, args, kwargs))