This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients gvanrossum, vstinner, yselivanov
Date 2016-09-21.07:50:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I noticed the following warning in test_asyncio (see above). It understand that when the asyncio Future ("destination" in _chain_future) is cancelled, _call_check_cancel() calls source_loop.call_soon_threadsafe(source.cancel) where source is a concurrent.futures.Future object.

Then futures.Future.cancel() calls self._invoke_callbacks() which calls _call_set_state() of _chain_future(). _call_set_state() calls dest_loop.call_soon_threadsafe(_set_state, destination, source) but at this point, the event loop is closed. Morever, destination (the asyncio future) is already cancelled, but it doesn't make sense to try to copy the state: source and destination are already cancelled.

I suggest to modify _call_set_state() to do nothing if destination is already cancelled:

    def _call_set_state(source):
        if destination.cancelled():

*But* I see that futures.Future has a set_running_or_notify_cancel() method which seems to be important to call. Maybe we should call it in this case?

    def _call_set_state(source):
        if destination.cancelled():


The warning:

test_sock_sendall (test.test_asyncio.test_selector_events.BaseSelectorEventLoopTests) ... exception calling callback for <Future at 0xec840d1e28 state=finished returned NoneType>
Traceback (most recent call last):
  File "D:\buildarea\3.6.bolen-windows8\build\lib\concurrent\futures\", line 297, in _invoke_callbacks
  File "D:\buildarea\3.6.bolen-windows8\build\lib\asyncio\", line 462, in _call_set_state
    dest_loop.call_soon_threadsafe(_set_state, destination, source)
  File "D:\buildarea\3.6.bolen-windows8\build\lib\asyncio\", line 603, in call_soon_threadsafe
    handle = self._call_soon(callback, args)
  File "D:\buildarea\3.6.bolen-windows8\build\lib\asyncio\", line 577, in _call_soon
  File "D:\buildarea\3.6.bolen-windows8\build\lib\asyncio\", line 356, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Date User Action Args
2016-09-21 07:50:41vstinnersetrecipients: + vstinner, gvanrossum, yselivanov
2016-09-21 07:50:41vstinnersetmessageid: <>
2016-09-21 07:50:41vstinnerlinkissue28232 messages
2016-09-21 07:50:40vstinnercreate