diff options
author | 2015-06-09 14:08:48 +0000 | |
---|---|---|
committer | 2015-06-09 14:08:48 +0000 | |
commit | 96810930ff1470867e8ac6ef5c2173fc42f0feb8 (patch) | |
tree | 495759a9b29ee40832bc641fe360bf7259027438 /dev-python/txaio/files/util.py | |
parent | Updating remote-id in metadata.xml (diff) | |
download | gentoo-2-96810930ff1470867e8ac6ef5c2173fc42f0feb8.tar.gz gentoo-2-96810930ff1470867e8ac6ef5c2173fc42f0feb8.tar.bz2 gentoo-2-96810930ff1470867e8ac6ef5c2173fc42f0feb8.zip |
ebuild written by me, new runtime dep to autobahn-0.10.4
(Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key 0xB8072B0D)
Diffstat (limited to 'dev-python/txaio/files/util.py')
-rw-r--r-- | dev-python/txaio/files/util.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/dev-python/txaio/files/util.py b/dev-python/txaio/files/util.py new file mode 100644 index 000000000000..254df70a5aac --- /dev/null +++ b/dev-python/txaio/files/util.py @@ -0,0 +1,40 @@ +try: + import asyncio + from asyncio.test_utils import run_once as _run_once + + def run_once(): + return _run_once(asyncio.get_event_loop()) + +except ImportError as e: + try: + import trollius as asyncio + except ImportError: + asyncio = None + + def run_once(): + ''' + copied from asyncio.testutils because trollius has no + "testutils" + ''' + # in Twisted, this method is a no-op + if asyncio is None: + return + + # just like modern asyncio.testutils.run_once does it... + loop = asyncio.get_event_loop() + loop.stop() + loop.run_forever() + asyncio.gather(*asyncio.Task.all_tasks()) + + +try: + # XXX fixme hack better way to detect twisted + # (has to work on py3 where asyncio exists always, though) + import twisted # noqa + + def await(_): + return + +except ImportError: + def await(future): + asyncio.get_event_loop().run_until_complete(future) |