summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_thread.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_thread.py')
-rw-r--r--Lib/test/test_thread.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py
index c4c21fe..5705798 100644
--- a/Lib/test/test_thread.py
+++ b/Lib/test/test_thread.py
@@ -21,10 +21,10 @@ def task(ident):
delay = random.random() * numtasks
rmutex.release()
if verbose:
- print 'task', ident, 'will run for', round(delay, 1), 'sec'
+ print('task', ident, 'will run for', round(delay, 1), 'sec')
time.sleep(delay)
if verbose:
- print 'task', ident, 'done'
+ print('task', ident, 'done')
mutex.acquire()
running = running - 1
if running == 0:
@@ -37,7 +37,7 @@ def newtask():
mutex.acquire()
next_ident = next_ident + 1
if verbose:
- print 'creating task', next_ident
+ print('creating task', next_ident)
thread.start_new_thread(task, (next_ident,))
running = running + 1
mutex.release()
@@ -45,9 +45,9 @@ def newtask():
for i in range(numtasks):
newtask()
-print 'waiting for all tasks to complete'
+print('waiting for all tasks to complete')
done.acquire()
-print 'all tasks done'
+print('all tasks done')
class barrier:
def __init__(self, n):
@@ -89,13 +89,13 @@ def task2(ident):
delay = random.random() * numtasks
rmutex.release()
if verbose:
- print 'task', ident, 'will run for', round(delay, 1), 'sec'
+ print('task', ident, 'will run for', round(delay, 1), 'sec')
time.sleep(delay)
if verbose:
- print 'task', ident, 'entering barrier', i
+ print('task', ident, 'entering barrier', i)
bar.enter()
if verbose:
- print 'task', ident, 'leaving barrier', i
+ print('task', ident, 'leaving barrier', i)
mutex.acquire()
running -= 1
# Must release mutex before releasing done, else the main thread can
@@ -106,7 +106,7 @@ def task2(ident):
if finished:
done.release()
-print '\n*** Barrier Test ***'
+print('\n*** Barrier Test ***')
if done.acquire(0):
raise ValueError, "'done' should have remained acquired"
bar = barrier(numtasks)
@@ -114,10 +114,10 @@ running = numtasks
for i in range(numtasks):
thread.start_new_thread(task2, (i,))
done.acquire()
-print 'all tasks done'
+print('all tasks done')
# not all platforms support changing thread stack size
-print '\n*** Changing thread stack size ***'
+print('\n*** Changing thread stack size ***')
if thread.stack_size() != 0:
raise ValueError, "initial stack_size not 0"
@@ -132,10 +132,10 @@ if os_name in ("nt", "os2", "posix"):
try:
thread.stack_size(4096)
except ValueError:
- print 'caught expected ValueError setting stack_size(4096)'
+ print('caught expected ValueError setting stack_size(4096)')
except thread.error:
tss_supported = 0
- print 'platform does not support changing thread stack size'
+ print('platform does not support changing thread stack size')
if tss_supported:
failed = lambda s, e: s != e
@@ -144,17 +144,17 @@ if os_name in ("nt", "os2", "posix"):
thread.stack_size(tss)
if failed(thread.stack_size(), tss):
raise ValueError, fail_msg % tss
- print 'successfully set stack_size(%d)' % tss
+ print('successfully set stack_size(%d)' % tss)
for tss in (262144, 0x100000):
- print 'trying stack_size = %d' % tss
+ print('trying stack_size = %d' % tss)
next_ident = 0
for i in range(numtasks):
newtask()
- print 'waiting for all tasks to complete'
+ print('waiting for all tasks to complete')
done.acquire()
- print 'all tasks done'
+ print('all tasks done')
# reset stack size to default
thread.stack_size(0)