Merge pull request #88 from oberstet/txaio_261

add sleep helper; some cosmetics
This commit is contained in:
Tobias Oberstein 2017-02-09 15:49:21 +01:00 committed by GitHub
commit cb0af20708
7 changed files with 63 additions and 26 deletions

View File

@ -65,14 +65,11 @@ Please refer to the `documentation <https://txaio.readthedocs.io/en/latest/>`_ f
.. |Version| image:: https://img.shields.io/pypi/v/txaio.svg
:target: https://pypi.python.org/pypi/txaio
.. |Master Branch| image:: https://img.shields.io/badge/branch-master-orange.svg
:target: https://travis-ci.org/crossbario/txaio.svg?branch=master
.. |Build Status| image:: https://travis-ci.org/crossbario/txaio.svg?branch=master
:target: https://travis-ci.org/crossbario/txaio
.. |Coverage| image:: https://img.shields.io/codecov/c/github/crossbario/txaio/master.svg
.. |Coverage| image:: https://codecov.io/github/crossbario/txaio/coverage.svg?branch=master
:target: https://codecov.io/github/crossbario/txaio
.. |Docs| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat
.. |Docs| image:: https://readthedocs.org/projects/txaio/badge/?version=latest
:target: https://txaio.readthedocs.io/en/latest/

View File

@ -1,9 +1,17 @@
txio releases
=============
2.6.1
-----
- February 9, 2017
- added inline sleep helper (Twisted only for now)
2.6.0
-----
- December 29, 2016
- avoid giving negative times to `callLater` with batched timers (issue #81)

View File

@ -65,34 +65,36 @@ __all__ = (
'config', # the config instance, access via attributes
'create_future', # create a Future (can be already resolved/errored)
'create_future', # create a Future (can be already resolved/errored)
'create_future_success',
'create_future_error',
'create_failure', # return an object implementing IFailedFuture
'as_future', # call a method, and always return a Future
'is_future', # True for Deferreds in tx and Futures, @coroutines in asyncio
'reject', # errback a Future
'resolve', # callback a Future
'add_callbacks', # add callback and/or errback
'gather', # return a Future waiting for several other Futures
'is_called', # True if the Future has a result
'create_failure', # return an object implementing IFailedFuture
'as_future', # call a method, and always return a Future
'is_future', # True for Deferreds in tx and Futures, @coroutines in asyncio
'reject', # errback a Future
'resolve', # callback a Future
'add_callbacks', # add callback and/or errback
'gather', # return a Future waiting for several other Futures
'is_called', # True if the Future has a result
'call_later', # call the callback after the given delay seconds
'call_later', # call the callback after the given delay seconds
'failure_message', # a printable error-message from a IFailedFuture
'failure_traceback', # returns a traceback instance from an IFailedFuture
'failure_format_traceback', # a string, the formatted traceback
'failure_message', # a printable error-message from a IFailedFuture
'failure_traceback', # returns a traceback instance from an IFailedFuture
'failure_format_traceback', # a string, the formatted traceback
'make_batched_timer', # create BatchedTimer/IBatchedTimer instances
'make_batched_timer', # create BatchedTimer/IBatchedTimer instances
'make_logger', # creates an object implementing ILogger
'start_logging', # initializes logging (may grab stdin at this point)
'set_global_log_level', # Set the global log level
'get_global_log_level', # Get the global log level
'make_logger', # creates an object implementing ILogger
'start_logging', # initializes logging (may grab stdin at this point)
'set_global_log_level', # Set the global log level
'get_global_log_level', # Get the global log level
'add_log_categories',
'IFailedFuture', # describes API for arg to errback()s
'ILogger', # API for logging
'IFailedFuture', # describes API for arg to errback()s
'ILogger', # API for logging
'sleep', # little helper for inline sleeping
)

View File

@ -75,3 +75,5 @@ add_log_categories = _throw_usage_error
IFailedFuture = _throw_usage_error
ILogger = _throw_usage_error
sleep = _throw_usage_error

View File

@ -1 +1 @@
__version__ = u'2.6.0'
__version__ = u'2.6.1'

View File

@ -424,3 +424,15 @@ def set_global_log_level(level):
def get_global_log_level():
return _log_level
def sleep(delay, loop=None):
"""
Inline sleep for use in co-routines.
:param delay: Time to sleep in seconds.
:type delay: float
:param reactor: The asyncio loop to use.
:type reactor: None (to use the default loop) or a loop.
"""
raise Exception('not implemented yet')

View File

@ -536,3 +536,19 @@ def set_global_log_level(level):
def get_global_log_level():
return _log_level
def sleep(delay, reactor=None):
"""
Inline sleep for use in co-routines.
:param delay: Time to sleep in seconds.
:type delay: float
:param reactor: The Twisted reactor to use.
:type reactor: None or provider of ``IReactorTime``.
"""
if not reactor:
from twisted.internet import reactor
d = Deferred()
reactor.callLater(delay, d.callback, None)
return d