text stringlengths 0 828 |
|---|
1334,"def shutdown(self, wait=True): |
"""""" |
Shut down the pool. If *wait* is True, it will wait until all futures |
are completed. Alternatively, you can use the #wait() method to wait |
with timeout supported. |
"""""" |
with self._lock: |
self._shutdown = True |
self._lock.notify_all() |
if wait: |
self.wait()" |
1335,"def wait(self, timeout=None): |
"""""" |
Wait until all futures are completed. You should call this method only |
after calling #shutdown(). Returns #False if all futures are complete, |
#False if there are still some running. |
"""""" |
tbegin = _get_timeout_begin(timeout) |
with self._lock: |
while self._queue or self._running: |
remainder = _get_timeout_remainder(tbegin, timeout) |
if remainder is not None and remainder <= 0.0: |
return False # timeout |
self._lock.wait(remainder) |
if self._shutdown: |
for worker in self._workers: |
worker.join() |
return True" |
1336,"def timeit(func): |
"""""" |
Returns the number of seconds that a function took along with the result |
"""""" |
@wraps(func) |
def timer_wrapper(*args, **kwargs): |
"""""" |
Inner function that uses the Timer context object |
"""""" |
with Timer() as timer: |
result = func(*args, **kwargs) |
return result, timer |
return timer_wrapper" |
1337,"def timeout(seconds): |
"""""" |
Raises a TimeoutError if a function does not terminate within |
specified seconds. |
"""""" |
def _timeout_error(signal, frame): |
raise TimeoutError(""Operation did not finish within \ |
{} seconds"".format(seconds)) |
def timeout_decorator(func): |
@wraps(func) |
def timeout_wrapper(*args, **kwargs): |
signal.signal(signal.SIGALRM, _timeout_error) |
signal.alarm(seconds) |
try: |
return func(*args, **kwargs) |
finally: |
signal.alarm(0) |
return timeout_wrapper |
return timeout_decorator" |
1338,"def create(location: str, extensions_found: List[str] = None): # -> NoParserFoundForObject: |
"""""" |
Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests |
ERROR: type should be string, got " https://github.com/nose-devs/nose/issues/725" |
:param location: |
:param extensions_found: |
:return: |
"""""" |
if not extensions_found: |
return ObjectPresentMultipleTimesOnFileSystemError('Object : ' + location + ' is present multiple ' |
'times on the file system.') |
else: |
return ObjectPresentMultipleTimesOnFileSystemError('Object : ' + location + ' is present multiple ' |
'times on the file system , with extensions : ' + |
str(extensions_found) + '. Only one version of each ' |
'object should be provided. If you need multiple files' |
' to create this object, you should create a multifile' |
' object instead (with each file having its own name and' |
' a shared prefix)')" |
1339,"def create(location: str, simpleobjects_found = None, complexobject_attributes_found = None): # -> ObjectNotFoundOnFileSystemError: |
"""""" |
Helper method provided because we actually can't put that in the constructor, it creates a bug in Nose tests |
ERROR: type should be string, got " https://github.com/nose-devs/nose/issues/725" |
:param location: |
:return: |
"""""" |
if len(complexobject_attributes_found) > 0 or len(simpleobjects_found) > 0: |
return ObjectNotFoundOnFileSystemError('Mandatory object : ' + location + ' could not be found on the file' |
' system, either as a multifile or as a singlefile with any ' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.