Message353415
| Author |
gregory.p.smith |
| Recipients |
Mark.Shannon, deleted0524, erik.bray, gregory.p.smith, jdemeyer, ncoghlan, njs, rhettinger, ryanhiebert, serhiy.storchaka, xgdomingo, yselivanov |
| Date |
2019年09月27日.21:20:31 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1569619231.21.0.103838758001.issue29988@roundup.psfhosted.org> |
| In-reply-to |
| Content |
As a note on the general pattern, a user at work diagnosed a ^C problem in their code when running on 2.7 to be due to Queue.get's
acquire()
try:
...
finally:
release()
Pattern, with the KeyboardInterrupt triggering after acquire() but before the try is entered. so release() is never called.
A try finally pattern that probably alleviates this by entering the try block first might look like:
try:
acquire()
...
finally:
try:
release()
except ThreadError:
pass # interrupted before acquire() succeeded.
It'd be a shame if any with statements lock acquisition context managers need to be turned into that, but I _believe_ it'd be a viable workaround for the time being if this race is found to be biting anyone. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2019年09月27日 21:20:31 | gregory.p.smith | set | recipients:
+ gregory.p.smith, rhettinger, ncoghlan, njs, Mark.Shannon, erik.bray, serhiy.storchaka, jdemeyer, yselivanov, deleted0524, ryanhiebert, xgdomingo |
| 2019年09月27日 21:20:31 | gregory.p.smith | set | messageid: <1569619231.21.0.103838758001.issue29988@roundup.psfhosted.org> |
| 2019年09月27日 21:20:31 | gregory.p.smith | link | issue29988 messages |
| 2019年09月27日 21:20:31 | gregory.p.smith | create |
|