dabeaz / curio

Good Curio!
Other
4.04k stars 243 forks source link

Expose daemon param with @async_thread #179

Closed Fuyukai closed 7 years ago

Fuyukai commented 7 years ago

I have a few async threads that I want to die when I kill my application, instead of waiting the ~40 or so seconds on a condition that will never be set. It would be great if using just the decorator I could mark these as daemon instead of having to reboot the kernel and kill them manually.

Additionally, the daemon property of these async threads don't seem to be used - they're not passed to the underlying threading.Thread.

dabeaz commented 7 years ago

A bit curious to get more information. Are the threads waiting on a Curio condition variable or an external one? It's my goal for async threads to be cancellable like normal Curio tasks--although that only works if they're blocked waiting for something in the context of Curio though.

In any case, will look at the daemon status further...

Fuyukai commented 7 years ago

They're waiting on a curio condition value.

dabeaz commented 7 years ago

Hmmm. So the idea is that they'd just die the same way a normal daemonic task would then? I will look into this. It's slightly tricky since every async thread consists of both a Curio task and a real-life thread at the same time. It seems as if this should be possible though.

dabeaz commented 7 years ago

Pushed some changes related to this. Give it a whirl.

Fuyukai commented 7 years ago

This seems to kill as expected without having to do anything hacky, thanks!