Comments (2)
Note, this appears to actually be a bug (or a footgun) in Python. The polars-free code below deadlocks if you comment out the nonlocal count
line. The reproducible example code above works (no deadlock) if you add nonlocal df
to the top of the worker coroutine. Please feel free to close this issue.
import asyncio
async def arange(count):
for i in range(count):
yield(i)
await asyncio.sleep(0)
async def main():
# Initialize number.
count = 0
# Define a queue of data to process.
limit = 3
queue = asyncio.Queue(limit)
# Define a worker task to do the processing.
async def worker():
nonlocal count
while True:
# Get the next item to process from the queue.
item = await queue.get()
# Increment the count.
count = count + 1
# Tell the queue we are done with this item.
queue.task_done()
# Launch some asynchronous worker tasks to process the queue.
tasks = set()
for _ in range(limit):
tasks.add(asyncio.create_task(worker()))
# Add some items to the queue.
async for item in arange(100):
# Put each item in the queue.
await queue.put(item)
# Wait until the queue is processed.
await queue.join()
# Then cancel the worker tasks.
for task in tasks:
task.cancel()
for task in tasks:
try:
await task
except asyncio.CancelledError:
pass
return count
if __name__ == '__main__':
count = asyncio.run(main())
print(count)
from polars.
In that case I'll close this issue. Thanks for looking into it.
from polars.
Related Issues (20)
- BinViewChunkedBuilder has incorrect docs
- Series.hist resulting series name changes with include_breakpoint=False, include_category=False HOT 1
- Series.hist adds two bins when specifying bins HOT 1
- data spilled to disk not cleaned up on failure HOT 1
- Cannot serialize polars.LazyFrame (`Expr::RenameAlias cannot be serialized`)
- Big difference in iteration speed over GroupBy object depending on dataFrame construction HOT 1
- Can't `sink_parquet` on a sorted LazyFrame containing decimal columns HOT 2
- `write_database` closes adbc connection HOT 3
- `list_concat([list<T>, list<T>])` gives `list<T>`, not `list<list<T>>` HOT 10
- mismatching schemas when opening csv file
- SchemaError for Non-Exiting dtype on Concat HOT 1
- LazyFrame select in 0.20.31 includes hive partition column even when not in specified columns HOT 2
- cross-join should not work on any key HOT 1
- `.sink_parquet()` sometimes panics when `statistics` has `"null_count": False` HOT 1
- separate `pl.list()` and `pl.concat_list` HOT 4
- Panick since first release candidate when expressions in `select()` return a different number of rows HOT 1
- Question, how do you generate and test the Python examples in the README? HOT 1
- min/max operations on i16 list with None elements HOT 1
- Panic when drop nulls
- `write_database` fails for UInts and Time dtypes when ADBC used HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polars.