New submission from Brian McCutchon :
Consider the following code:
# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0
import contextlib
import os
@contextlib.contextmanager
def my_tmp_file():
with tempfile.NamedTemporaryFile('w') as f:
yield f
os.stat(m
New submission from Brian McCutchon :
Currently, it is possible to make a basic single-threaded executor for unit
testing:
class FakeExecutor(futures.Executor):
def submit(self, f, *args, **kwargs):
future = futures.Future()
future.set_result(f(*args, **kwargs))
return future
Brian McCutchon added the comment:
Mostly nondeterminism. It seems like creating a ThreadPoolExecutor with one
worker could still be nondeterministic, as there are two threads: the main
thread and the worker thread. It gets worse if multiple executors are needed.
Another option would be to
Brian McCutchon added the comment:
I understand your hesitation to add a fake. Would it be better to make it
possible to subclass Executor so that a third party implementation of this can
be developed?
As for an example, here is an example of nondeterminism when using a
ThreadPoolExecutor
Brian McCutchon added the comment:
No, I do not have such an example, as most of my tests try to fake the
executors.
--
___
Python tracker
<https://bugs.python.org/issue36