[issue33238] AssertionError on await of Future returned by asyncio.wrap_future

2018-05-30 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33238] AssertionError on await of Future returned by asyncio.wrap_future

2018-05-30 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset 0a28c0d12ee7201de039ced4d815f57f1f8fd48c by Andrew Svetlov 
(jhaydaman) in branch 'master':
bpo-33238: Add InvalidStateError to concurrent.futures. (GH-7056)
https://github.com/python/cpython/commit/0a28c0d12ee7201de039ced4d815f57f1f8fd48c


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33238] AssertionError on await of Future returned by asyncio.wrap_future

2018-05-22 Thread Jason Haydaman

Change by Jason Haydaman :


--
keywords: +patch
pull_requests: +6690
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33238] AssertionError on await of Future returned by asyncio.wrap_future

2018-05-21 Thread Andrew Svetlov

Change by Andrew Svetlov :


--
versions: +Python 3.8 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33238] AssertionError on await of Future returned by asyncio.wrap_future

2018-05-21 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Raising `InvalidStateError` sounds perfect.

Would you make a pull request?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33238] AssertionError on await of Future returned by asyncio.wrap_future

2018-04-06 Thread Jason Haydaman

Jason Haydaman  added the comment:

May also be worth pointing out that even in the case of only calling set_result 
once, _done_callbacks still has _chain_future in it:


import asyncio
import concurrent.futures


f = concurrent.futures.Future()
async_f = asyncio.wrap_future(f)

f.set_result(1)
loop = asyncio.get_event_loop()
print(loop.run_until_complete(async_f))
print(f._done_callbacks)


>>> 1
>>> [._call_set_state at 0x7f1687f3c620>]


Should that be cleared by that point?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33238] AssertionError on await of Future returned by asyncio.wrap_future

2018-04-06 Thread Jason Haydaman

New submission from Jason Haydaman :

When the concurrent Future wrapped by asyncio.wrap_future has set_result or 
set_exception called multiple times, I get the following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/events.py", line 145, in _run
self._callback(*self._args)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 399, in _set_state
_copy_future_state(other, future)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 369, in 
_copy_future_state
assert not dest.done()
AssertionError


Minimal reproducible example:

import asyncio
import concurrent.futures

f = concurrent.futures.Future()
async_f = asyncio.wrap_future(f)
f.set_result(1)
f.set_result(1)

loop = asyncio.get_event_loop()
loop.run_until_complete(async_f)


The documentation says that set_result and set_exception are only meant for 
Executors, so, arguably using them outside of that context would fall into 
undocumented behavior rather than a bug. But it still seems like it should be 
the second set_result that raises something like InvalidStateError. 
Alternatively, this can be avoided if _copy_future_state checks for done in 
addition to cancellation. What should happen here?

--
components: Library (Lib), asyncio
messages: 315030
nosy: Jason Haydaman, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: AssertionError on await of Future returned by asyncio.wrap_future
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com