@@ -13,7 +13,6 @@ |
|
|
13 |
13 |
import tempfile |
14 |
14 |
import threading |
15 |
15 |
import unittest |
16 |
|
-import multiprocessing |
17 |
16 |
from unittest import mock |
18 |
17 |
from test import support |
19 |
18 |
|
@@ -1793,37 +1792,6 @@ def create_watcher(self): |
|
|
1793 |
1792 |
return asyncio.FastChildWatcher() |
1794 |
1793 |
|
1795 |
1794 |
|
1796 |
|
-class ForkedProcessTests(unittest.TestCase): |
1797 |
|
-def setUp(self): |
1798 |
|
-self.parent_loop = asyncio.SelectorEventLoop() |
1799 |
|
-asyncio.set_event_loop(self.parent_loop) |
1800 |
|
-self.ctx = multiprocessing.get_context("fork") |
1801 |
|
- |
1802 |
|
-def tearDown(self): |
1803 |
|
-self.parent_loop.close() |
1804 |
|
- |
1805 |
|
-def _check_loops_not_equal(self, old_loop): |
1806 |
|
-loop = asyncio.get_event_loop() |
1807 |
|
-if loop is old_loop: |
1808 |
|
-raise RuntimeError("Child process inherited parent's event loop") |
1809 |
|
- |
1810 |
|
-try: |
1811 |
|
-val = loop.run_until_complete(asyncio.sleep(0.05, result=42)) |
1812 |
|
-if val != 42: |
1813 |
|
-raise RuntimeError("new event loop does not work") |
1814 |
|
-finally: |
1815 |
|
-loop.close() |
1816 |
|
- |
1817 |
|
-sys.exit(loop is old_loop) |
1818 |
|
- |
1819 |
|
-def test_new_loop_in_child(self): |
1820 |
|
-p = self.ctx.Process(target=self._check_loops_not_equal, |
1821 |
|
-args=(self.parent_loop,)) |
1822 |
|
-p.start() |
1823 |
|
-p.join() |
1824 |
|
-self.assertEqual(p.exitcode, 0) |
1825 |
|
- |
1826 |
|
- |
1827 |
1795 |
class PolicyTests(unittest.TestCase): |
1828 |
1796 |
|
1829 |
1797 |
def create_policy(self): |