bpo-33238: Add InvalidStateError to concurrent.futures. (GH-7056)
Future.set_result and Future.set_exception now raise InvalidStateError if the futures are not pending or running. This mirrors the behavior of asyncio.Future, and prevents AssertionErrors in asyncio.wrap_future when set_result is called multiple times.
This commit is contained in:
committed by
Andrew Svetlov
parent
bb9474f1fb
commit
0a28c0d12e
@@ -1,17 +1,13 @@
|
||||
__all__ = ()
|
||||
|
||||
import concurrent.futures._base
|
||||
import concurrent.futures
|
||||
import reprlib
|
||||
|
||||
from . import format_helpers
|
||||
|
||||
Error = concurrent.futures._base.Error
|
||||
CancelledError = concurrent.futures.CancelledError
|
||||
TimeoutError = concurrent.futures.TimeoutError
|
||||
|
||||
|
||||
class InvalidStateError(Error):
|
||||
"""The operation is not allowed in this state."""
|
||||
InvalidStateError = concurrent.futures.InvalidStateError
|
||||
|
||||
|
||||
# States for Future.
|
||||
|
||||
Reference in New Issue
Block a user