ntjohnson1 commented on issue #366:
URL:
https://github.com/apache/datafusion-python/issues/366#issuecomment-3313995576
```python
from __future__ import annotations
from multiprocessing import cpu_count
from multiprocessing.pool import ThreadPool
import datafusion as dfn
def run_threads() -> None:
ctx = dfn.SessionContext()
with ThreadPool(cpu_count()) as pool:
results = []
for i in range(100):
results.append(pool.apply_async(make_dataframe, args=(ctx, i)))
for result in results:
result.get()
def make_dataframe(ctx: dfn.SessionContext, i: int) -> None:
df = ctx.from_pydict({"a": [i]})
df.write_parquet(f"output_{i}.parquet")
if __name__ == "__main__":
run_threads()
```
`RuntimeError: Already borrowed`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]