mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-05 16:27:44 +00:00
47 lines
764 B
Python
47 lines
764 B
Python
from concurrent.futures import ThreadPoolExecutor
|
|
import asyncio
|
|
import random
|
|
import time
|
|
|
|
se = set()
|
|
def fun(arg):
|
|
while True:
|
|
time.sleep(10)
|
|
print('sleep')
|
|
# print('sleeping')
|
|
# await asyncio.sleep(random.randint(1, 10))
|
|
# print('wake up')
|
|
|
|
|
|
def nuf():
|
|
while True:
|
|
# time.sleep(5)
|
|
print('awake')
|
|
|
|
|
|
def main(f):
|
|
asyncio.run(f())
|
|
|
|
|
|
async def run():
|
|
# loop = asyncio.get_running_loop()
|
|
with ThreadPoolExecutor(max_workers=10) as exe:
|
|
exe.submit(fun, 10)
|
|
exe.submit(nuf)
|
|
# r.cancel()
|
|
# print(r.done())
|
|
# return r.result()
|
|
|
|
|
|
|
|
asyncio.run(run())
|
|
|
|
# ars = (1, 3, 4)
|
|
#
|
|
# def check(f, args):
|
|
# print(*args)
|
|
#
|
|
#
|
|
# b = {check: (3, ars)}
|
|
|
|
# [k(v[0], v[1]) for k,v in b.items()] |