Timeout (version 0.0.1)
index
Timeout.html

This package implements tools to build python package and tools.
 
>>> from Timeout import *
>>> from time import sleep
>>> class A:
...     def __init__(self):
...         self.a = "a"
...
>>> @thread_timeout(2)
... def test():
...     while 1:
...         print("pass")
...         sleep(1)
...
>>> test()
pass
pass
pass
Traceback (most recent call last):
    ...
TimeoutError: TimeoutError in "test"
Traceback (most recent call last):
    ...
KeyboardInterrupt
>>> @thread_timeout(2)
... def test():
...     print("pass")
...     sleep(1)
...     return A()
...
>>> test()
pass
<__main__.A object at ...>
>>> @signal_timeout(2)
... def test():
...     while 1:
...         print("pass")
...         sleep(1)
...
>>> test()
pass
pass
pass
Traceback (most recent call last):
    ...
TimeoutError
>>> @signal_timeout(2)
... def test():
...     print("pass")
...     sleep(1)
...     return A()
...
>>> test()
pass
<__main__.A object at ...>
>>> @process_timeout(2)
... def test():
...     print("pass")
...     sleep(1)
...     return A()
...
>>> test()
pass
<__main__.A object at ...>
>>> @process_timeout(2)
... def test():
...     while 1:
...         print("pass")
...         sleep(1)
...
>>> test()
pass
pass
pass
Traceback (most recent call last):
    ...
TimeoutError: TimeoutError in "test"
Traceback (most recent call last):
    ...
KeyboardInterrupt

 
Functions
       
process_timeout(seconds: int) -> collections.abc.Callable
This decorator implements a function timeout.
thread_timeout(seconds: int) -> collections.abc.Callable
This decorator implements a function timeout.

 
Data
        __all__ = ['thread_timeout', 'process_timeout']
__annotations__ = {'current_pid': <class 'str'>, 'pid': <class 'str'>}
__author_email__ = 'mauricelambert434@gmail.com'
__copyright__ = '\nPythonToolsKit Copyright (C) 2022 Maurice Lam...ome to redistribute it\nunder certain conditions.\n'
__description__ = '\nThis package implements tools to build python package and tools.\n'
__license__ = 'GPL-3.0 License'
__maintainer__ = 'Maurice Lambert'
__maintainer_email__ = 'mauricelambert434@gmail.com'
__url__ = 'https://github.com/mauricelambert/PythonToolsKit'

 
Author
        Maurice Lambert
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy