curio v1.3 Release Notes

Release Date: 2020-08-23 // over 1 year ago
  • 🚚 08/21/2020 Moved the Pytest plugin to the examples directory. There have been several reported problems with it. It is no longer installed by default. It was never used by Curio itself.

    06/16/2020 Refined the detection of coroutines to use collections.abc.Coroutine. This change should not affect any existing part of Curio, but it allows it to properly recognize async functions defined in extensions such as Cython. See Issue #326.

    06/11/2020 Added a Result object. It's like an Event except that it has a an associated value/exception attached to it. Here's the basic usage pattern:

               result = Result()
               ...
               async def do_work():
                   try:
                       ...
                       await result.set_value(value)
                   except Exception as e:
                       await result.set_exception(e)
    
               async def some_task():
                   ...
                   try:
                       value = await result.unwrap() 
                       print("Success:", value)
                   except Exception as e:
                       print("Fail:", e)
    
           In this example, the unwrap() method blocks until the result
           becomes available.
    

    06/09/2020 Having now needed it a few projects, have added a UniversalResult object. It allows Curio tasks or threads to wait for a result to be set by another thread or task. For example:

               def do_work(result):
                   ...
                   result.set_value(value)
    
               async def some_task(result):
                   ...
                   value = await result.unwrap()
                   ...
    
               result = UniversalResult()
               threading.Thread(target=do_work, args=[result]).start()
               curio.run(some_task, result)
    
           UniversalResult is somewhat similar to a Future.  However, it
           really only allows setting and waiting.  There are no callbacks,
           cancellation, or any other extras.