Merge pull request #88 from oberstet/txaio_261
add sleep helper; some cosmetics
This commit is contained in:
		@@ -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
 | 
					.. |Version| image:: https://img.shields.io/pypi/v/txaio.svg
 | 
				
			||||||
   :target: https://pypi.python.org/pypi/txaio
 | 
					   :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
 | 
					.. |Build Status| image:: https://travis-ci.org/crossbario/txaio.svg?branch=master
 | 
				
			||||||
   :target: https://travis-ci.org/crossbario/txaio
 | 
					   :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
 | 
					   :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/
 | 
					   :target: https://txaio.readthedocs.io/en/latest/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,17 @@
 | 
				
			|||||||
txio releases
 | 
					txio releases
 | 
				
			||||||
=============
 | 
					=============
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2.6.1
 | 
				
			||||||
 | 
					-----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- February 9, 2017
 | 
				
			||||||
 | 
					- added inline sleep helper (Twisted only for now)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2.6.0
 | 
					2.6.0
 | 
				
			||||||
-----
 | 
					-----
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- December 29, 2016
 | 
				
			||||||
- avoid giving negative times to `callLater` with batched timers (issue #81)
 | 
					- avoid giving negative times to `callLater` with batched timers (issue #81)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,34 +65,36 @@ __all__ = (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    'config',                   # the config instance, access via attributes
 | 
					    '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_success',
 | 
				
			||||||
    'create_future_error',
 | 
					    'create_future_error',
 | 
				
			||||||
    'create_failure',  # return an object implementing IFailedFuture
 | 
					    'create_failure',           # return an object implementing IFailedFuture
 | 
				
			||||||
    'as_future',       # call a method, and always return a Future
 | 
					    'as_future',                # call a method, and always return a Future
 | 
				
			||||||
    'is_future',       # True for Deferreds in tx and Futures, @coroutines in asyncio
 | 
					    'is_future',                # True for Deferreds in tx and Futures, @coroutines in asyncio
 | 
				
			||||||
    'reject',          # errback a Future
 | 
					    'reject',                   # errback a Future
 | 
				
			||||||
    'resolve',         # callback a Future
 | 
					    'resolve',                  # callback a Future
 | 
				
			||||||
    'add_callbacks',   # add callback and/or errback
 | 
					    'add_callbacks',            # add callback and/or errback
 | 
				
			||||||
    'gather',          # return a Future waiting for several other Futures
 | 
					    'gather',                   # return a Future waiting for several other Futures
 | 
				
			||||||
    'is_called',       # True if the Future has a result
 | 
					    '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_message',          # a printable error-message from a IFailedFuture
 | 
				
			||||||
    'failure_traceback',  # returns a traceback instance from an IFailedFuture
 | 
					    'failure_traceback',        # returns a traceback instance from an IFailedFuture
 | 
				
			||||||
    'failure_format_traceback',  # a string, the formatted traceback
 | 
					    '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
 | 
					    'make_logger',              # creates an object implementing ILogger
 | 
				
			||||||
    'start_logging',   # initializes logging (may grab stdin at this point)
 | 
					    'start_logging',            # initializes logging (may grab stdin at this point)
 | 
				
			||||||
    'set_global_log_level',  # Set the global log level
 | 
					    'set_global_log_level',     # Set the global log level
 | 
				
			||||||
    'get_global_log_level',  # Get the global log level
 | 
					    'get_global_log_level',     # Get the global log level
 | 
				
			||||||
    'add_log_categories',
 | 
					    'add_log_categories',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    'IFailedFuture',             # describes API for arg to errback()s
 | 
					    'IFailedFuture',            # describes API for arg to errback()s
 | 
				
			||||||
    'ILogger',                   # API for logging
 | 
					    'ILogger',                  # API for logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    'sleep',                    # little helper for inline sleeping
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,3 +75,5 @@ add_log_categories = _throw_usage_error
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
IFailedFuture = _throw_usage_error
 | 
					IFailedFuture = _throw_usage_error
 | 
				
			||||||
ILogger = _throw_usage_error
 | 
					ILogger = _throw_usage_error
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sleep = _throw_usage_error
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
__version__ = u'2.6.0'
 | 
					__version__ = u'2.6.1'
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								txaio/aio.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								txaio/aio.py
									
									
									
									
									
								
							@@ -424,3 +424,15 @@ def set_global_log_level(level):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def get_global_log_level():
 | 
					def get_global_log_level():
 | 
				
			||||||
    return _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')
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								txaio/tx.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								txaio/tx.py
									
									
									
									
									
								
							@@ -536,3 +536,19 @@ def set_global_log_level(level):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
def get_global_log_level():
 | 
					def get_global_log_level():
 | 
				
			||||||
    return _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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user