You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
523 B
25 lines
523 B
5 years ago
|
from gevent import monkey; monkey.patch_all()
|
||
|
import threading
|
||
|
|
||
|
|
||
|
localdata = threading.local()
|
||
|
localdata.x = "hello"
|
||
|
assert localdata.x == 'hello'
|
||
|
success = []
|
||
|
|
||
|
|
||
|
def func():
|
||
|
try:
|
||
|
getattr(localdata, 'x')
|
||
|
raise AssertionError('localdata.x must raise AttributeError')
|
||
|
except AttributeError:
|
||
|
pass
|
||
|
assert localdata.__dict__ == {}, localdata.__dict__
|
||
|
success.append(1)
|
||
|
|
||
|
t = threading.Thread(None, func)
|
||
|
t.start()
|
||
|
t.join()
|
||
|
assert success == [1], 'test failed'
|
||
|
assert localdata.x == 'hello'
|