-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle a ThreadHandleType * handle special case of _thread._ExceptHookArgs * use threading.ExceptHookArgs for pypy * handle when thread doesn't have native_id
- Loading branch information
Showing
2 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Author: Mike McKerns (mmckerns @caltech and @uqfoundation) | ||
# Copyright (c) 2024 The Uncertainty Quantification Foundation. | ||
# License: 3-clause BSD. The full license text is available at: | ||
# - https://github.com/uqfoundation/dill/blob/master/LICENSE | ||
|
||
import dill | ||
dill.settings['recurse'] = True | ||
|
||
|
||
def test_new_thread(): | ||
import threading | ||
t = threading.Thread() | ||
t_ = dill.copy(t) | ||
assert t.is_alive() == t_.is_alive() | ||
for i in ['daemon','name','ident','native_id']: | ||
if hasattr(t, i): | ||
assert getattr(t, i) == getattr(t_, i) | ||
|
||
def test_run_thread(): | ||
import threading | ||
t = threading.Thread() | ||
t.start() | ||
t_ = dill.copy(t) | ||
assert t.is_alive() == t_.is_alive() | ||
for i in ['daemon','name','ident','native_id']: | ||
if hasattr(t, i): | ||
assert getattr(t, i) == getattr(t_, i) | ||
|
||
def test_join_thread(): | ||
import threading | ||
t = threading.Thread() | ||
t.start() | ||
t.join() | ||
t_ = dill.copy(t) | ||
assert t.is_alive() == t_.is_alive() | ||
for i in ['daemon','name','ident','native_id']: | ||
if hasattr(t, i): | ||
assert getattr(t, i) == getattr(t_, i) | ||
|
||
|
||
if __name__ == '__main__': | ||
test_new_thread() | ||
test_run_thread() | ||
test_join_thread() |