FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-22087: Fix Policy.get_event_loop() to detect fork by 1st1 · Pull Request #7208 · python/cpython · GitHub

/ cpython Public
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Prev Previous commit
More tests
  • Loading branch information
Yury Selivanov committed May 29, 2018
commit 0bd8ecbd8cc3ab15b8a54af47c32fc9da7113b06
17 changes: 14 additions & 3 deletions Lib/test/test_asyncio/test_unix_events.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1811,18 +1811,29 @@ def setUp(self):
asyncio.set_event_loop(self.parent_loop)
self.ctx = multiprocessing.get_context("fork")

def tearDown(self):
self.parent_loop.close()

def _check_loops_not_equal(self, old_loop):
loop = asyncio.get_event_loop()
if loop is old_loop:
raise RuntimeError("Child process inherited parent's event loop")

try:
val = loop.run_until_complete(asyncio.sleep(0.05, result=42))
if val != 42:
raise RuntimeError("new event loop does not work")
finally:
loop.close()

sys.exit(loop is old_loop)

def test_new_loop_in_child(self):
p = self.ctx.Process(target=self._check_loops_not_equal,
args=(self.parent_loop,))
p.start()
p.join()
self.assertEqual(p.exitcode, 0,
"Child process inherited parent's event loop")
self.parent_loop.close()
self.assertEqual(p.exitcode, 0)


class PolicyTests(unittest.TestCase):
Expand Down

Back | FazBrowse Home | New Git URL