mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-34679: Restore instantiation Windows IOCP event loop from non-main thread (#15492)
* Restore running proactor event loop from non-main thread Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
This commit is contained in:
parent
998cf1f03a
commit
1c06009986
3 changed files with 24 additions and 1 deletions
|
|
@ -59,6 +59,25 @@ class ProactorLoopCtrlC(test_utils.TestCase):
|
|||
thread.join()
|
||||
|
||||
|
||||
class ProactorMultithreading(test_utils.TestCase):
|
||||
def test_run_from_nonmain_thread(self):
|
||||
finished = False
|
||||
|
||||
async def coro():
|
||||
await asyncio.sleep(0)
|
||||
|
||||
def func():
|
||||
nonlocal finished
|
||||
loop = asyncio.new_event_loop()
|
||||
loop.run_until_complete(coro())
|
||||
finished = True
|
||||
|
||||
thread = threading.Thread(target=func)
|
||||
thread.start()
|
||||
thread.join()
|
||||
self.assertTrue(finished)
|
||||
|
||||
|
||||
class ProactorTests(test_utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue