Код: Выделить всё
a
Код: Выделить всё
b
Иллюстрация: < /p>
Код: Выделить всё
q = very_magic_queue.Queue()
def worker_of_a(q):
while True:
q.put(1)
time.sleep(1)
a = threading.Thread(worker_of_a, args=(q,))
a.start()
async def loop(q):
while True:
# v must be processed in the same order as they are produced
v = await q.get()
print(v)
async def foo():
pass
async def b_main(q):
loop_fut = asyncio.ensure_future(loop(q))
foo_fut = asyncio.ensure_future(foo())
_ = await asyncio.wait([loop_fut, foo_fut], ...)
# blah blah blah
def worker_of_b(q):
asyncio.set_event_loop(asyncio.new_event_loop())
asyncio.get_event_loop().run_until_complete(b_main(q))
b = threading.Thread(worker_of_b, args=(q,))
b.start()
Мне также нужен канал связи от b до .
Я был бы здорово, если бы решение также могло работать с Gevent < /code>. < /p>
Спасибо

Подробнее здесь: https://stackoverflow.com/questions/558 ... -in-python