Hi,

2014-03-03 23:59 GMT+01:00 Nikolay Kim <[email protected]>:
> I see "InvalidStateError: CANCELLED: Future<CANCELLED>” exception in my 
> production system.
> It doesn’t really affect application logic, just annoying. also it is very 
> hard to understand where exception from.
> so i propose to add safe_set_result() method to Future that will check status 
> before setting result.
> code review is here https://codereview.appspot.com/69870048/

I didn't understood with your example what happens. In fact, the
future is cancelled before future.set_result() is called. Something
like:
---
fut = Future()
<do something else>
fut.cancel()
<do something else>
fut.set_result()
---
where "<do something else>" is a side-effect of asynchronous
programming and "yield from".

Checking the future status before scheduling the call (with
loop.call_soon) to set_result() would not fix the issue.

If I understood correctly, _SelectorSocketTransport constructor
doesn't call directly set_result() (but use loop.call_soon instead) to
wait until protocol.connection_made() has been called. So
loop.create_connection() only returns the socket when
protocol.connection_made() has been called. Is this correct?

_SelectorSocketTransport constructor cannot call directly
protocol.connection_made()?

Victor

Reply via email to