It seems like this hack would be fine for notebooks, but not something I’d be interested in for production code.
Why not just something like this?
def f(n):
time.sleep(random.uniform(0.1, 0.3)) # Simulate network delay
return pd.DataFrame({"A": [n, n+1], "B": [n*2, (n+1)*2]})
with ThreadPoolExecutor() as ex:
df = pd.concat(ex.map(f, range(3)), ignore_index=True)
replies(2):