1############################################################################### 2# 3# The MIT License (MIT) 4# 5# Copyright (c) Crossbar.io Technologies GmbH 6# 7# Permission is hereby granted, free of charge, to any person obtaining a copy 8# of this software and associated documentation files (the "Software"), to deal 9# in the Software without restriction, including without limitation the rights 10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11# copies of the Software, and to permit persons to whom the Software is 12# furnished to do so, subject to the following conditions: 13# 14# The above copyright notice and this permission notice shall be included in 15# all copies or substantial portions of the Software. 16# 17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23# THE SOFTWARE. 24# 25############################################################################### 26 27""" 28This provides a version of the API which only throws exceptions; 29this is the default so that you have to pick asyncio or twisted 30explicitly by calling .use_twisted() or .use_asyncio() 31""" 32 33from __future__ import absolute_import, division, print_function 34from txaio import _Config 35 36using_twisted = False 37using_asyncio = False 38config = _Config() 39 40 41def _throw_usage_error(*args, **kw): 42 raise RuntimeError( 43 "To use txaio, you must first select a framework " 44 "with .use_twisted() or .use_asyncio()" 45 ) 46 47 48# all the txaio API methods just raise the error 49with_config = _throw_usage_error 50create_future = _throw_usage_error 51create_future_success = _throw_usage_error 52create_future_error = _throw_usage_error 53create_failure = _throw_usage_error 54as_future = _throw_usage_error 55is_future = _throw_usage_error 56reject = _throw_usage_error 57cancel = _throw_usage_error 58resolve = _throw_usage_error 59add_callbacks = _throw_usage_error 60gather = _throw_usage_error 61is_called = _throw_usage_error 62 63call_later = _throw_usage_error 64 65failure_message = _throw_usage_error 66failure_traceback = _throw_usage_error 67failure_format_traceback = _throw_usage_error 68 69make_batched_timer = _throw_usage_error 70 71make_logger = _throw_usage_error 72start_logging = _throw_usage_error 73set_global_log_level = _throw_usage_error 74get_global_log_level = _throw_usage_error 75 76add_log_categories = _throw_usage_error 77 78IFailedFuture = _throw_usage_error 79ILogger = _throw_usage_error 80 81sleep = _throw_usage_error 82