-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gracefully cancel move #5
Comments
Thanks for this suggestion. Currently this isn't implemented. The most general solution to always clean up (including if an exception occurred in the loop) would be adding yet another context manager to work around the fact that for loops don't get "closed". From an API standpoint I find this proliferation of context managers a bit annoying, but I guess unavoidable... Of course exposing the DICOM c_cancel operation in some lower level way as you requested also seems to make sense. |
Thanks for your reply. Is the application of additional context managers already possible somehow? If yes, I would be very grateful if you could provide a minimal working example. |
No this isn't currently possible, but it is something I would like to have implemented soon. I think the best API would be to have the In the mean time as a workaround, you could do an |
I just created PR #8 which is an attempt to address this, please try it out. I want to try to figure out some tests before merging. I forgot async generators do have an async with aclosing(local.retrieve(remote, query_res=my_qr)) as ret:
async for instance_ds in ret:
if my_cond:
break |
After some iterations, I finally think the code in that PR is converging on the correct behavior. Unfortunately some pynetdicom functions (e.g. |
This is largely addressed by PR #8 that is now merged, except for the potential for a long timeout (~3 minutes) during the cleanup. Whether or not you experience this timeout depends also on server behavior (i.e. does it close the connection on its end when it sees it). Improving this would really need to happen at the pynetdicom level, and my idea about just abandoning blocked threads doesn't work because we need them to release any network ports. So given all that, the above work around (just retrieve the subset you want) is still the best option for now. I will leave this issue open to track the slow timeout problem. |
Is it possible to send a c_cancel, e.g., to gracefully interrupt the move of a series?
The text was updated successfully, but these errors were encountered: