Python _thread.TIMEOUT_MAX Examples
The following are 5
code examples of _thread.TIMEOUT_MAX().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
_thread
, or try the search function
.
Example #1
Source File: lock_tests.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def test_timeout(self): lock = self.locktype() # Can't set timeout if not blocking self.assertRaises(ValueError, lock.acquire, 0, 1) # Invalid timeout values self.assertRaises(ValueError, lock.acquire, timeout=-100) self.assertRaises(OverflowError, lock.acquire, timeout=1e100) self.assertRaises(OverflowError, lock.acquire, timeout=TIMEOUT_MAX + 1) # TIMEOUT_MAX is ok lock.acquire(timeout=TIMEOUT_MAX) lock.release() t1 = time.time() self.assertTrue(lock.acquire(timeout=5)) t2 = time.time() # Just a sanity test that it didn't actually wait for the timeout. self.assertLess(t2 - t1, 5) results = [] def f(): t1 = time.time() results.append(lock.acquire(timeout=0.5)) t2 = time.time() results.append(t2 - t1) Bunch(f, 1).wait_for_finished() self.assertFalse(results[0]) self.assertTimeout(results[1], 0.5)
Example #2
Source File: lock_tests.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_timeout(self): lock = self.locktype() # Can't set timeout if not blocking self.assertRaises(ValueError, lock.acquire, 0, 1) # Invalid timeout values self.assertRaises(ValueError, lock.acquire, timeout=-100) self.assertRaises(OverflowError, lock.acquire, timeout=1e100) self.assertRaises(OverflowError, lock.acquire, timeout=TIMEOUT_MAX + 1) # TIMEOUT_MAX is ok lock.acquire(timeout=TIMEOUT_MAX) lock.release() t1 = time.time() self.assertTrue(lock.acquire(timeout=5)) t2 = time.time() # Just a sanity test that it didn't actually wait for the timeout. self.assertLess(t2 - t1, 5) results = [] def f(): t1 = time.time() results.append(lock.acquire(timeout=0.5)) t2 = time.time() results.append(t2 - t1) Bunch(f, 1).wait_for_finished() self.assertFalse(results[0]) self.assertTimeout(results[1], 0.5)
Example #3
Source File: lock_tests.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def test_timeout(self): lock = self.locktype() # Can't set timeout if not blocking self.assertRaises(ValueError, lock.acquire, 0, 1) # Invalid timeout values self.assertRaises(ValueError, lock.acquire, timeout=-100) self.assertRaises(OverflowError, lock.acquire, timeout=1e100) self.assertRaises(OverflowError, lock.acquire, timeout=TIMEOUT_MAX + 1) # TIMEOUT_MAX is ok lock.acquire(timeout=TIMEOUT_MAX) lock.release() t1 = time.time() self.assertTrue(lock.acquire(timeout=5)) t2 = time.time() # Just a sanity test that it didn't actually wait for the timeout. self.assertLess(t2 - t1, 5) results = [] def f(): t1 = time.time() results.append(lock.acquire(timeout=0.5)) t2 = time.time() results.append(t2 - t1) Bunch(f, 1).wait_for_finished() self.assertFalse(results[0]) self.assertTimeout(results[1], 0.5)
Example #4
Source File: lock_tests.py From android_universal with MIT License | 6 votes |
def test_timeout(self): lock = self.locktype() # Can't set timeout if not blocking self.assertRaises(ValueError, lock.acquire, 0, 1) # Invalid timeout values self.assertRaises(ValueError, lock.acquire, timeout=-100) self.assertRaises(OverflowError, lock.acquire, timeout=1e100) self.assertRaises(OverflowError, lock.acquire, timeout=TIMEOUT_MAX + 1) # TIMEOUT_MAX is ok lock.acquire(timeout=TIMEOUT_MAX) lock.release() t1 = time.monotonic() self.assertTrue(lock.acquire(timeout=5)) t2 = time.monotonic() # Just a sanity test that it didn't actually wait for the timeout. self.assertLess(t2 - t1, 5) results = [] def f(): t1 = time.monotonic() results.append(lock.acquire(timeout=0.5)) t2 = time.monotonic() results.append(t2 - t1) Bunch(f, 1).wait_for_finished() self.assertFalse(results[0]) self.assertTimeout(results[1], 0.5)
Example #5
Source File: start.py From Starx_Pixiv_Collector with MIT License | 5 votes |
def download_thread(url, path, exfile_name=None, exfile_dir=None): tag = 'Download_Thread' wait_for_limit() local_path = path give_it_a_sign = False local_filename = url.split('/')[-1] if local_filename.endswith('zip'): give_it_a_sign = True if exfile_dir is not None: local_path += exfile_dir + global_symbol if exfile_name is not None: local_filename = exfile_name + "-" + local_filename path_output = local_path + local_filename print_with_tag(tag, ["File Location:" + path_output]) if not os.path.exists(local_path): print_with_tag(tag, "Folder doesn't exists!!") os.makedirs(local_path) print_with_tag(tag, "Folder Created.") retry_count = 0 while True: try: _thread.TIMEOUT_MAX = 60 _thread.start_new_thread(download_file, (url, path_output, give_it_a_sign)) except: print_with_tag(tag, "Error.") if retry_count == 3: print_with_tag(tag, "Not wokring..") print_with_tag(tag, "Skip!!") else: print_with_tag(tag, "Starting retry..") retry_count += 1 else: print_with_tag(tag, "Download thread successfully started!") break print_with_tag(tag, ['Threads_count:', str(current_threads)])