Python asyncio.DefaultEventLoopPolicy() Examples
The following are 30
code examples of asyncio.DefaultEventLoopPolicy().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
asyncio
, or try the search function
.
Example #1
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_get_event_loop_returns_running_loop(self): class Policy(asyncio.DefaultEventLoopPolicy): def get_event_loop(self): raise NotImplementedError loop = None old_policy = asyncio.get_event_loop_policy() try: asyncio.set_event_loop_policy(Policy()) loop = asyncio.new_event_loop() self.assertIs(asyncio._get_running_loop(), None) async def func(): self.assertIs(asyncio.get_event_loop(), loop) self.assertIs(asyncio._get_running_loop(), loop) loop.run_until_complete(func()) finally: asyncio.set_event_loop_policy(old_policy) if loop is not None: loop.close() self.assertIs(asyncio._get_running_loop(), None)
Example #2
Source File: pytest_plugin.py From Galaxy_Plugin_Bethesda with MIT License | 5 votes |
def pytest_generate_tests(metafunc): # type: ignore if 'loop_factory' not in metafunc.fixturenames: return loops = metafunc.config.option.aiohttp_loop avail_factories = {'pyloop': asyncio.DefaultEventLoopPolicy} if uvloop is not None: # pragma: no cover avail_factories['uvloop'] = uvloop.EventLoopPolicy if tokio is not None: # pragma: no cover avail_factories['tokio'] = tokio.EventLoopPolicy if loops == 'all': loops = 'pyloop,uvloop?,tokio?' factories = {} # type: ignore for name in loops.split(','): required = not name.endswith('?') name = name.strip(' ?') if name not in avail_factories: # pragma: no cover if required: raise ValueError( "Unknown loop '%s', available loops: %s" % ( name, list(factories.keys()))) else: continue factories[name] = avail_factories[name] metafunc.parametrize("loop_factory", list(factories.values()), ids=list(factories.keys()))
Example #3
Source File: test_unix_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def create_policy(self): return asyncio.DefaultEventLoopPolicy()
Example #4
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_set_event_loop_policy(self): self.assertRaises( AssertionError, asyncio.set_event_loop_policy, object()) old_policy = asyncio.get_event_loop_policy() policy = asyncio.DefaultEventLoopPolicy() asyncio.set_event_loop_policy(policy) self.assertIs(policy, asyncio.get_event_loop_policy()) self.assertIsNot(policy, old_policy)
Example #5
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_new_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() loop = policy.new_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) loop.close()
Example #6
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_get_event_loop_thread(self, m_current_thread): def f(): policy = asyncio.DefaultEventLoopPolicy() self.assertRaises(RuntimeError, policy.get_event_loop) th = threading.Thread(target=f) th.start() th.join()
Example #7
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_get_event_loop_after_set_none(self): policy = asyncio.DefaultEventLoopPolicy() policy.set_event_loop(None) self.assertRaises(RuntimeError, policy.get_event_loop)
Example #8
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_get_event_loop_calls_set_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() with mock.patch.object( policy, "set_event_loop", wraps=policy.set_event_loop) as m_set_event_loop: loop = policy.get_event_loop() # policy._local._loop must be set through .set_event_loop() # (the unix DefaultEventLoopPolicy needs this call to attach # the child watcher correctly) m_set_event_loop.assert_called_with(loop) loop.close()
Example #9
Source File: test_events.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_get_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() self.assertIsNone(policy._local._loop) loop = policy.get_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) self.assertIs(policy._local._loop, loop) self.assertIs(loop, policy.get_event_loop()) loop.close()
Example #10
Source File: test_unix_events.py From annotated-py-projects with MIT License | 5 votes |
def create_policy(self): return asyncio.DefaultEventLoopPolicy()
Example #11
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def test_set_event_loop_policy(self): self.assertRaises( AssertionError, asyncio.set_event_loop_policy, object()) old_policy = asyncio.get_event_loop_policy() policy = asyncio.DefaultEventLoopPolicy() asyncio.set_event_loop_policy(policy) self.assertIs(policy, asyncio.get_event_loop_policy()) self.assertIsNot(policy, old_policy)
Example #12
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def test_new_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() loop = policy.new_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) loop.close()
Example #13
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def test_get_event_loop_thread(self, m_current_thread): def f(): policy = asyncio.DefaultEventLoopPolicy() self.assertRaises(RuntimeError, policy.get_event_loop) th = threading.Thread(target=f) th.start() th.join()
Example #14
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def test_get_event_loop_after_set_none(self): policy = asyncio.DefaultEventLoopPolicy() policy.set_event_loop(None) self.assertRaises(RuntimeError, policy.get_event_loop)
Example #15
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def test_get_event_loop_calls_set_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() with mock.patch.object( policy, "set_event_loop", wraps=policy.set_event_loop) as m_set_event_loop: loop = policy.get_event_loop() # policy._local._loop must be set through .set_event_loop() # (the unix DefaultEventLoopPolicy needs this call to attach # the child watcher correctly) m_set_event_loop.assert_called_with(loop) loop.close()
Example #16
Source File: test_events.py From annotated-py-projects with MIT License | 5 votes |
def test_get_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() self.assertIsNone(policy._local._loop) loop = policy.get_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) self.assertIs(policy._local._loop, loop) self.assertIs(loop, policy.get_event_loop()) loop.close()
Example #17
Source File: test_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_get_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() self.assertIsNone(policy._local._loop) loop = policy.get_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) self.assertIs(policy._local._loop, loop) self.assertIs(loop, policy.get_event_loop()) loop.close()
Example #18
Source File: test_unix_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def create_policy(self): return asyncio.DefaultEventLoopPolicy()
Example #19
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_set_event_loop_policy(self): self.assertRaises( AssertionError, asyncio.set_event_loop_policy, object()) old_policy = asyncio.get_event_loop_policy() policy = asyncio.DefaultEventLoopPolicy() asyncio.set_event_loop_policy(policy) self.assertIs(policy, asyncio.get_event_loop_policy()) self.assertIsNot(policy, old_policy)
Example #20
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_new_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() loop = policy.new_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) loop.close()
Example #21
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_get_event_loop_thread(self, m_current_thread): def f(): policy = asyncio.DefaultEventLoopPolicy() self.assertRaises(RuntimeError, policy.get_event_loop) th = threading.Thread(target=f) th.start() th.join()
Example #22
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_get_event_loop_after_set_none(self): policy = asyncio.DefaultEventLoopPolicy() policy.set_event_loop(None) self.assertRaises(RuntimeError, policy.get_event_loop)
Example #23
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_get_event_loop_calls_set_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() with mock.patch.object( policy, "set_event_loop", wraps=policy.set_event_loop) as m_set_event_loop: loop = policy.get_event_loop() # policy._local._loop must be set through .set_event_loop() # (the unix DefaultEventLoopPolicy needs this call to attach # the child watcher correctly) m_set_event_loop.assert_called_with(loop) loop.close()
Example #24
Source File: test_events.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_get_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() self.assertIsNone(policy._local._loop) loop = policy.get_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) self.assertIs(policy._local._loop, loop) self.assertIs(loop, policy.get_event_loop()) loop.close()
Example #25
Source File: glib_events.py From pychess with GNU General Public License v3.0 | 5 votes |
def __init__(self, application=None): self._default_loop = None self._application = application self._watcher_lock = threading.Lock() self._watcher = None self._policy = asyncio.DefaultEventLoopPolicy() self._policy.new_event_loop = self.new_event_loop self.get_event_loop = self._policy.get_event_loop self.set_event_loop = self._policy.set_event_loop
Example #26
Source File: test_unix_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def create_policy(self): return asyncio.DefaultEventLoopPolicy()
Example #27
Source File: test_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_set_event_loop_policy(self): self.assertRaises( AssertionError, asyncio.set_event_loop_policy, object()) old_policy = asyncio.get_event_loop_policy() policy = asyncio.DefaultEventLoopPolicy() asyncio.set_event_loop_policy(policy) self.assertIs(policy, asyncio.get_event_loop_policy()) self.assertIsNot(policy, old_policy)
Example #28
Source File: test_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_new_event_loop(self): policy = asyncio.DefaultEventLoopPolicy() loop = policy.new_event_loop() self.assertIsInstance(loop, asyncio.AbstractEventLoop) loop.close()
Example #29
Source File: test_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_get_event_loop_thread(self, m_current_thread): def f(): policy = asyncio.DefaultEventLoopPolicy() self.assertRaises(RuntimeError, policy.get_event_loop) th = threading.Thread(target=f) th.start() th.join()
Example #30
Source File: test_events.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_get_event_loop_after_set_none(self): policy = asyncio.DefaultEventLoopPolicy() policy.set_event_loop(None) self.assertRaises(RuntimeError, policy.get_event_loop)