• Home
  • Raw
  • Download

Lines Matching full:thread

10 thread = test.test_support.import_module('thread')  variable
35 class TestThread(threading.Thread):
37 threading.Thread.__init__(self, name=name)
93 t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
112 # The ident still must work for the main thread and dummy threads.
119 thread.start_new_thread(f, ())
125 # run with a small(ish) thread stack size (256kB)
128 print 'with 256kB thread stack size...'
131 except thread.error:
132 self.skipTest('platform does not support changing thread stack size')
136 # run with a large thread stack size (1MB)
139 print 'with 1MB thread stack size...'
142 except thread.error:
143 self.skipTest('platform does not support changing thread stack size')
148 # Check that a "foreign" thread can use the threading module.
151 # thread to get made in the threading._active map.
157 tid = thread.start_new_thread(f, (mutex,))
158 # Wait for the thread to finish.
179 # First check it works when setting the exception from the same thread.
180 tid = thread.get_ident()
195 self.assertEqual(result, 1) # one thread state modified
200 # `worker_started` is set by the thread when it's inside a try/except
202 # `worker_saw_exception` is set by the thread upon catching that
207 class Worker(threading.Thread):
209 self.id = thread.get_ident()
224 print " started worker thread"
226 # Try a thread id that doesn't make sense.
228 print " trying nonsensical thread id"
230 self.assertEqual(result, 0) # no thread states modified
232 # Now raise an exception in the worker thread.
234 print " waiting for worker thread to get started"
243 self.assertEqual(result, 1) # one thread state modified
252 # else the thread is still running, and we have no way to kill it
255 # Issue 7481: Failure to start thread should cleanup the limbo map.
257 raise thread.error()
261 t = threading.Thread(target=lambda: None)
262 self.assertRaises(thread.error, t.start)
265 "Failed to cleanup _limbo map on failure of Thread.start().")
271 # very late on python exit: on deallocation of a running thread for
279 import ctypes, sys, time, thread
282 ready = thread.allocate_lock()
299 thread.start_new_thread(waitingThread, ())
300 ready.acquire() # Be sure the other thread is waiting.
318 t = threading.Thread(target=killer)
348 # As a non-daemon thread we SHOULD wake up and nothing
352 threading.Thread(target=child).start()
366 # Try hard to trigger #1703448: a thread is still returned in
372 # Try a couple times at each thread-switching interval
375 t = threading.Thread(target=lambda: None)
387 # The links in this refcycle from Thread back to self
388 # should be cleaned up when the thread completes.
390 self.thread = threading.Thread(target=self._run,
393 self.thread.start()
401 cyclic_object.thread.join()
409 raising_cyclic_object.thread.join()
417 # Issue #14308: a dummy thread in the active list doesn't mess up
420 import thread, threading, os, time
429 thread.start_new_thread(background_thread, (evt,))
453 t = threading.Thread(target=lambda: None)
469 threads = [threading.Thread(target=bs.acquire)
475 threads = [threading.Thread(target=bs.release)
486 # #12316 and #11870), and fork() from a worker thread is known to trigger
496 # a thread, which waits for the main program to terminate
499 print 'end of thread'
506 self.assertEqual(data, "end of main\nend of thread\n")
511 # The usual case: on exit, wait for a non-daemon thread
514 t = threading.Thread(target=joiningfunc,
533 t = threading.Thread(target=joiningfunc,
543 # Like the test above, but fork() was called from a worker thread
544 # In the forked process, the main Thread object must be marked as stopped.
553 t = threading.Thread(target=joiningfunc,
559 w = threading.Thread(target=worker)
576 # thread. See http://bugs.python.org/issue6643.
579 # - The main thread in the parent process starts a new thread and then
581 # - The join operation acquires the Lock inside the thread's _block
582 # Condition. (See threading.py:Thread.join().)
584 # until the child thread forks. (See LOCK ACQUIRED HERE)
585 # - The child thread forks. (See LOCK HELD and WORKER THREAD FORKS
587 # - The main thread of the parent process enters Condition.wait(),
588 # which releases the lock on the child thread.
590 # main thread of the child process (which used to be the child thread
592 # lock in the Thread._block Condition object and hang, because the
602 # Wait until this thread's lock is acquired before forking to
607 # LOCK HELD: Main thread holds lock across this call.
615 w = threading.Thread(target=worker)
634 time.sleep(0.01) # WORKER THREAD FORKS HERE
648 # Check that a spawned thread that forks doesn't segfault on certain
650 # lock in the thread's condition variable's waiters list. Even though
665 # Wait until the main thread has attempted to join this thread
675 print('end of worker thread')
680 w = threading.Thread(target=worker)
698 print('end of main thread')
700 output = "end of worker thread\nend of main thread\n"
720 t = threading.Thread(target=do_fork_and_wait)
730 # Issue #14432: Crash when a generator is created in a C thread that is
733 # Python state of the destroyed C thread. The crash occurs when a trace
756 # Create a generator in a C thread which exits after the call
759 # Call the generator in a different Python thread, check that the
760 # generator didn't keep a reference to the destroyed thread state
769 # A RuntimeError should be raised if Thread.start() is called
772 thread = threading.Thread()
773 thread.start()
774 self.assertRaises(RuntimeError, thread.start)
781 thread = threading.Thread()
782 self.assertRaises(RuntimeError, thread.join)
785 thread = threading.Thread()
786 thread.start()
787 self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
801 t = threading.Thread(target=run)
810 self.assertIn("Exception in thread", err)
828 t = threading.Thread(target=run)
838 self.assertIn("Exception in thread", err)
857 t = threading.Thread(target=run)
894 # test that excessive recursion within a non-main thread causes
910 w = threading.Thread(target=outer)
913 print('end of main thread')
915 expected_output = "end of main thread\n"