In the threading module, one must of course only start a thread once. I have some questions about handling this gracefully. First of all, the documentation only says it is an error to start a thread more than once. It does not say which exception is raised. On my system I find it is AssertionError. So...is that going to be true on all systems? Is the test based on "assert", in which case it will go away for optimized code (and then what happens)? Anyway, if it is always AssertionError, I'd like to get the docs updated to say that. Also...if possible, it'd be nice to have some way to ask if a thread has ever been started. More generally, it'd be nice to be able to determine what state a thread is in. I'm not sure if there are any states other than ready to run, running and finished. If that's it, perhaps one could add methods isReady and didRun (a getState method would probably be better if there are more states, but then one has to deal with magic constants). I realize it is a common Python paradigm to assume something will work (such as starting the thread) and catch the exception if it doesn't, but: - this is tricky if the exception is not documented - sometimes one simply wants to know, without actually starting the thread -- Russell
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4