diff options
author | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:16:14 +0300 |
---|---|---|
committer | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:43:30 +0300 |
commit | b8cf9e88f4c5c64d9406af533d8948deb050d695 (patch) | |
tree | 218eb61fb3c3b96ec08b4d8cdfef383104a87d63 /contrib/python/Twisted/py3/twisted/_threads/_ithreads.py | |
parent | 523f645a83a0ec97a0332dbc3863bb354c92a328 (diff) | |
download | ydb-b8cf9e88f4c5c64d9406af533d8948deb050d695.tar.gz |
add kikimr_configure
Diffstat (limited to 'contrib/python/Twisted/py3/twisted/_threads/_ithreads.py')
-rw-r--r-- | contrib/python/Twisted/py3/twisted/_threads/_ithreads.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/contrib/python/Twisted/py3/twisted/_threads/_ithreads.py b/contrib/python/Twisted/py3/twisted/_threads/_ithreads.py new file mode 100644 index 00000000000..cab9135f874 --- /dev/null +++ b/contrib/python/Twisted/py3/twisted/_threads/_ithreads.py @@ -0,0 +1,61 @@ +# -*- test-case-name: twisted._threads.test -*- +# Copyright (c) Twisted Matrix Laboratories. +# See LICENSE for details. + +""" +Interfaces related to threads. +""" + + +from typing import Callable + +from zope.interface import Interface + + +class AlreadyQuit(Exception): + """ + This worker worker is dead and cannot execute more instructions. + """ + + +class IWorker(Interface): + """ + A worker that can perform some work concurrently. + + All methods on this interface must be thread-safe. + """ + + def do(task: Callable[[], None]) -> None: + """ + Perform the given task. + + As an interface, this method makes no specific claims about concurrent + execution. An L{IWorker}'s C{do} implementation may defer execution + for later on the same thread, immediately on a different thread, or + some combination of the two. It is valid for a C{do} method to + schedule C{task} in such a way that it may never be executed. + + It is important for some implementations to provide specific properties + with respect to where C{task} is executed, of course, and client code + may rely on a more specific implementation of C{do} than L{IWorker}. + + @param task: a task to call in a thread or other concurrent context. + @type task: 0-argument callable + + @raise AlreadyQuit: if C{quit} has been called. + """ + + def quit(): + """ + Free any resources associated with this L{IWorker} and cause it to + reject all future work. + + @raise AlreadyQuit: if this method has already been called. + """ + + +class IExclusiveWorker(IWorker): + """ + Like L{IWorker}, but with the additional guarantee that the callables + passed to C{do} will not be called exclusively with each other. + """ |