Author vstinner
Recipients gvanrossum, vstinner, yselivanov
Date 2016-09-21.07:50:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1474444241.28.0.930866863134.issue28232@psf.upfronthosting.co.za>
In-reply-to
Content
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():
            return
        (...)

*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():
            source.set_running_or_notify_cancel()
            return
        (...)

--

The warning:


http://buildbot.python.org/all/builders/AMD64%20Windows8%203.6/builds/43/steps/test/logs/stdio

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\_base.py", line 297, in _invoke_callbacks
    callback(self)
  File "D:\buildarea\3.6.bolen-windows8\build\lib\asyncio\futures.py", 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\base_events.py", line 603, in call_soon_threadsafe
    handle = self._call_soon(callback, args)
  File "D:\buildarea\3.6.bolen-windows8\build\lib\asyncio\base_events.py", line 577, in _call_soon
    self._check_closed()
  File "D:\buildarea\3.6.bolen-windows8\build\lib\asyncio\base_events.py", line 356, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
ok
History
Date User Action Args
2016-09-21 07:50:41vstinnersetrecipients: + vstinner, gvanrossum, yselivanov
2016-09-21 07:50:41vstinnersetmessageid: <1474444241.28.0.930866863134.issue28232@psf.upfronthosting.co.za>
2016-09-21 07:50:41vstinnerlinkissue28232 messages
2016-09-21 07:50:40vstinnercreate